View previous topic :: View next topic
Author
Message
saravanakumar N New User Joined: 24 Mar 2010Posts: 5 Location: Chennai
Hi
I need to convert input record's date format from DD-MMM-YY (29-OCT-08) to MM/DD/YYYY (10/29/2008). Can we do this using DFSORT or ICETOOL..?
my sample record is
1N4AA51E09C800016~29-OCT-08~TN
Back to top
Binop B Active User Joined: 18 Jun 2009Posts: 407 Location: Nashville, TN
Hi Saravana,
Yes, this can be done using DFSORT.
Tips : Looks into the usage of INREC - IFTHEN-WHEN - OUTREC.
Also, there are same or related topics aleady discussed in this forum.
*Note: Preferrably, when asking similiar kind of question, it is better to post the expected output record also.
And use 'code' button to display the record in a more readable form.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Code:
//DATECONV EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
ALL-OF-RECORD,1,30,CH
FIRST-PART-OF-RECORD,1,18,CH
MMM-IN-RECORD,22,3,CH
DD-IN-RECORD,19,2,CH
YY-IN-RECORD,26,2,CH
LAST-PART-OF-RECORD,28,3,CH
REFORMATTED-DATE,31,6,CH
//SORTIN DD *
1N4AA51E09C800016~29-OCT-08~TN
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(ALL-OF-RECORD,31:
MMM-IN-RECORD,
CHANGE=(2,C'JAN',C'01',C'FEB',C'02',C'MAR',C'03',C'APR',C'04',
C'MAY',C'05',C'JUN',C'06',C'JUL',C'07',C'AUG',C'08',
C'SEP',C'09',C'OCT',C'10',C'NOV',C'11',C'DEC',C'12'),
DD-IN-RECORD,
YY-IN-RECORD)),
IFTHEN=(WHEN=INIT,
BUILD=(FIRST-PART-OF-RECORD,
REFORMATTED-DATE,Y2W,EDIT=(TT/TT/TTTT),
LAST-PART-OF-RECORD))
Gives this output:
Code:
1N4AA51E09C800016~10/29/2008~TN
I "borrowed" the idea from the DFSORT Smart Tricks manual for how to do the names to numbers.
I suspect a cleaner solution will arrive.
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
Use the following DFSORT JCL which will give you the desired results. I assumed that the reformatted date is placed at pos 40 and your input lrecl=80 and recfm=fb
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
1N4AA51E09C800016~29-OCT-08~TN
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY,Y2PAST=1980
INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,OVERLAY=(81:22,3,19,2,26,2)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=81,
INOUT=(C'JAN',C'01',C'FEB',C'02',C'MAR',C'03',C'APR',C'04',
C'MAY',C'05',C'JUN',C'06',C'JUL',C'07',C'AUG',C'08',
C'SEP',C'09',C'OCT',C'10',C'NOV',C'11',C'DEC',C'12'))),
IFTHEN=(WHEN=INIT,OVERLAY=(40:81,6,Y2W(/)))
//*
Back to top
Please enable JavaScript!