View previous topic :: View next topic
Author
Message
cravisankar New User Joined: 12 Feb 2024Posts: 14 Location: India
Hi All,
I need help with SORT/DFSORT/ICETOOL in converting the date format. Below are the details for your reference. Please look into it and guide me:
1. My input file has a date column that prints date in 27 Aug 1993 format.
2. My requirement is, I want to convert 27 Aug 1993 format to 08/27/1993
Thanks in advance!!!
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1337 Location: Bamberg, Germany
You have tried what so far to achieve this?
Back to top
cravisankar New User Joined: 12 Feb 2024Posts: 14 Location: India
Honestly, I didn't tried as I am unaware of date format control cards. So, requesting for help. Once I get some experience with your inputs then next time onwards I will try the options before posting here.
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1337 Location: Bamberg, Germany
A simple demo. Complete the months in the CHANGE.
Code:
//WHATEVER EXEC PGM=ICEMAN
//SORTIN DD *
27 Aug 1993
1 Dec 2023
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%01=(STARTAT=NUM,ENDBEFR=BLANKS,FIXLEN=2),
%02=(STARTAT=UC,FIXLEN=3),
%03=(STARTAT=NUM,FIXLEN=4)),
BUILD=(%02,CHANGE=(2,C'Aug',C'08',
C'Sep',C'09',
C'Oct',C'10',
C'Nov',C'11',
C'Dec',C'12'),
C'/',%01,UFF,M11,C'/',%03)
END
Code:
****** ***************************
000001 08/27/1993
000002 12/01/2023
****** ***************************
Back to top
cravisankar New User Joined: 12 Feb 2024Posts: 14 Location: India
Thank you very much Joerg. I will try this and come back to you. However, it's my mistake that I didn't give proper input. Actually, my input file has 21k records. But with the given input by you, I think I will be able to convert date for all records.
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1337 Location: Bamberg, Germany
Sounds like a plan. For the PARSE you might need ABSPOS to indicate the starting position of the date field.
Back to top
cravisankar New User Joined: 12 Feb 2024Posts: 14 Location: India
Hi Jorge,
I tried ABSPOS with PARSE but getting error. Below is my input flat file and the date position is at column 129 and the control card that I tried. Please guide me accordingly enabling me to try again.
Code:
//WHATEVER EXEC PGM=ICEMAN
//SORTIN DD DSN=USERID.ABCD.SCNR.RPTR.XYZ,DISP=SHR
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=USERID.ABCD.SCNR.RPTR.XYZ.DATE,DISP=SHR
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(STARTAT=NUM,ENDBEFR=BLANKS,FIXLEN=2),
%02=(STARTAT=UC,FIXLEN=3),
%03=(STARTAT=NUM,FIXLEN=4),
%11=(ABSPOS=129,STARTAT=NUM,ENDBEFR=C'/',FIXLEN=11)
BUILD=(%02,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'),
C'/',%01,UFF,M11,C'/',%03,
%11,UFF,M11,C'/'))
SORT FIELDS=(COPY)
END
Code:
VIEW
Command ===>
=COLS> ---3----+----4-
****** ***************
000001 , 27 Aug 1993 ,
000002 , 15 Jul 2009 ,
000003 , 16 Dec 1993 ,
000004 , 5 Jul 1996 ,
000005 , 16 Feb 2009 ,
000006 , 17 Jan 2001 ,
000007 , 17 Jan 2001 ,
000008 , 14 Jul 1997 ,
000009 , 18 Oct 2012 ,
000010 , 28 Feb 2000 ,
000011 , 16 Nov 2006 ,
000012 , 28 Feb 2000 ,
000013 , 14 Nov 2002 ,
000014 , 28 Feb 2000 ,
000015 , 17 Jan 2001 ,
000016 , 17 Jan 2001 ,
000017 , 28 Feb 2000 ,
000018 , 18 Sep 2013 ,
000019 , 19 Aug 2022 ,
000020 , 26 Jul 2021 ,
000021 , 28 Feb 2000 ,
000022 , 17 Jan 2001 ,
000023 , 17 Jan 2001 ,
000024 , 27 Apr 2001 ,
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2141 Location: USA
cravisankar wrote:
I tried ABSPOS with PARSE but getting error.
1. Where is any example of ANY ERROR???
2. Compare of month names is CASE SENSITIVE!!!
3. You need to PARSE date elements at the position your date is ACTUALLY LOCATED.
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1337 Location: Bamberg, Germany
Use it like this to replace the field inline, and consider what @sergeyken has written.
Code:
OPTION COPY
INREC PARSE=(%01=(ABSPOS=129,STARTAT=NUM,ENDBEFR=BLANKS,FIXLEN=2),
%02=(STARTAT=UC,FIXLEN=3),
%03=(STARTAT=NUM,FIXLEN=4)),
OVERLAY=(129:%02,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'),C'/',
%01,UFF,M11,C'/',
%03,X)
END
Back to top
cravisankar New User Joined: 12 Feb 2024Posts: 14 Location: India
Hi Joerg & Sergeyken,
Many thanks for your quick support and this worked for me. Based on this, I will improve my skills in this area.
Back to top
Please enable JavaScript!