converting date field YYYYMMDD to a s9(7) Comp-3



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

converting date field YYYYMMDD to a s9(7) Comp-3

Postby rjambu » Wed Mar 09, 2011 11:54 pm

Hi,
Can anyone help me in converting a date field YYYYMMDD to a s9(7) Comp-3.

Input file:

AB80¦105¦000056-1¦1¦C102¦EA¦11021¦20110125¦
FG80¦105¦000056-1¦1¦C102¦EA¦11031¦20110125¦


The required output for the Column 7 and 8 should be of comp-3 value and its a date field
The output Column data should be with this defenition

Field Name Attribute Date Format
----------- ---------- ------------
Col7 03 JUL-DT PIC S9(5) COMP-3. julian YYDDD
Col8 03 TRXN-DT PIC S9(7) COMP-3. MMDDYY


//STEP010 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD  DSN=A.B.C,DISP=SHR     
//SORTOUT  DD  DSN=A.B.D,           
//             UNIT=DISK,SPACE=(TRK,(1,2),RLSE),   
//             DCB=(LRECL=35,BLKSIZE=0,RECFM=FB), 
//             DISP=(NEW,CATLG,DELETE)             
//SYSSORT  DD SYSOUT=*                             
//SYSUDUMP DD SYSOUT=*                             
//*                                                 
//SYSIN    DD  *                                   
 SORT FIELDS=COPY                                   
INREC PARSE=(%00=(ENDBEFR=X'6A',FIXLEN=05),
             %01=(ENDBEFR=X'6A',FIXLEN=03),
             %02=(ENDBEFR=X'6A',FIXLEN=06),
             %03=(ENDBEFR=X'6A',FIXLEN=01),
             %04=(ENDBEFR=X'6A',FIXLEN=05),
             %05=(ENDBEFR=X'6A',FIXLEN=02),
             %06=(ENDBEFR=X'6A',FIXLEN=05),
             %07=(ENDBEFR=X'6A',FIXLEN=08)),
  BUILD=(%00,%01,%02,%03,%04,%05,                                       X
         %06,UFF,PD,LENGTH=3,                                           X
         %07,UFF,PD,LENGTH=4)
/*
//


with the above JCL the column 8 i get different output when the data is loaded into the table

Input       output
20110125   11/1/2025


can any one help me in this regard.
Thanks
JRS
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: converting date field YYYYMMDD to a s9(7) Comp-3

Postby skolusu » Thu Mar 10, 2011 12:15 am

rjambu,

You Just can't take a CCYYMMDD date field and convert it to PD and expect it to be a MMDDYY date. You need to convert/move the fields appropriately before converting it to PD format. Assuming that your input always have 8 bytes of Gregorian date, the following DFSORT Control cards will give you the desired results. I am not sure as to why you need the continuation cards in pos 71 on the build statement.

//STEP0100 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD *                                     
AB80¦105¦000056-1¦1¦C102¦EA¦11021¦20110125¦         
FG80¦105¦000056-1¦1¦C102¦EA¦11031¦20110125¦         
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                     
  SORT FIELDS=COPY                                 
  INREC PARSE=(%00=(ENDBEFR=X'6A',FIXLEN=05),       
               %01=(ENDBEFR=X'6A',FIXLEN=03),       
               %02=(ENDBEFR=X'6A',FIXLEN=06),       
               %03=(ENDBEFR=X'6A',FIXLEN=01),       
               %04=(ENDBEFR=X'6A',FIXLEN=05),       
               %05=(ENDBEFR=X'6A',FIXLEN=02),       
               %06=(ENDBEFR=X'6A',FIXLEN=05),       
               %07=(ENDBEFR=X'6A',FIXLEN=08)),     
    BUILD=(%00,%01,%02,%03,%04,%05,                 
           %06,UFF,PD,LENGTH=3,%07,Y4T,TOGREG=Y2Y) 
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post