convert date to YMMDD Formate



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

convert date to YMMDD Formate

Postby rjambu » Sat Mar 12, 2011 12:13 am

Hi all,
I have a requirement that needs the date (YYYYMMDD) column 4 in the input file need to be converted to YMMDD.
The Input always have 8 bytes of Gregorian date for the Date field 3 and 4

Req output formate for the 2 date fields are below:

Col3 - MMDDYY
Col4 - YMMDD

I tried with the below JCL, but for Column 4 i not sure how to convert to 'YMMDD' Formate

Thanks JRS.
Input file:

AB80¦105¦20110125¦20110125¦
FG80¦105¦20110125¦20110125¦


//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=08),
             %03=(ENDBEFR=X'6A',FIXLEN=08)),
  BUILD=(%00,%01,%02,Y4T,TOGREG=Y2Y,%03,Y4T,TOGREG=Y2Y)                       

/*
//
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: convert date to YMMDD Formate

Postby Frank Yaeger » Sat Mar 12, 2011 12:46 am

I'm not sure why you're using PARSE considering that your fields all seem to be in fixed positions, but ...

You don't need to "Convert" the date in this case - you just need to move the pieces of the date around. Here's a DFSORT job that will do what you asked for:

//S1 EXEC PGM=SORT                                   
//SYSOUT DD SYSOUT=*                                 
//SORTDIAG DD DUMMY                                 
//SORTIN DD *                                       
AB80¦105¦20110125¦20110125¦                         
FG80¦105¦20110125¦20110125¦                         
QQQQ¦105¦20120507¦20131231¦                         
//SORTOUT DD SYSOUT=*                               
//SYSIN DD *                                         
  OPTION COPY                                       
  INREC IFTHEN=(WHEN=INIT,                           
   PARSE=(%00=(ENDBEFR=X'6A',FIXLEN=05),             
             %01=(ENDBEFR=X'6A',FIXLEN=03),         
             %02=(ENDBEFR=X'6A',FIXLEN=08),         
             %03=(ENDBEFR=X'6A',FIXLEN=08)),         
  BUILD=(%00,%01,%02,%03)),                         
 IFTHEN=(WHEN=INIT,                                 
   BUILD=(1,8,X,13,4,11,2,X,20,5))                   
/*


SORTOUT would have:

AB80 105 012511 10125   
FG80 105 012511 10125   
QQQQ 105 050712 31231   
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post