IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Modifying Date Format Using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 8
Location: India

PostPosted: Tue Feb 13, 2024 6:45 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1249
Location: Bamberg, Germany

PostPosted: Tue Feb 13, 2024 6:52 pm
Reply with quote

You have tried what so far to achieve this?
Back to top
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 8
Location: India

PostPosted: Tue Feb 13, 2024 6:57 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1249
Location: Bamberg, Germany

PostPosted: Tue Feb 13, 2024 7:07 pm
Reply with quote

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
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 8
Location: India

PostPosted: Tue Feb 13, 2024 7:57 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1249
Location: Bamberg, Germany

PostPosted: Tue Feb 13, 2024 8:14 pm
Reply with quote

Sounds like a plan. For the PARSE you might need ABSPOS to indicate the starting position of the date field.
Back to top
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 8
Location: India

PostPosted: Tue Feb 13, 2024 10:43 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2021
Location: USA

PostPosted: Wed Feb 14, 2024 12:47 am
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1249
Location: Bamberg, Germany

PostPosted: Wed Feb 14, 2024 7:53 am
Reply with quote

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
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 8
Location: India

PostPosted: Wed Feb 14, 2024 2:07 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top