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

Date converstion using DFSORT (DD-MMM-YY to MM/DD/YYYY)


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

New User


Joined: 24 Mar 2010
Posts: 5
Location: Chennai

PostPosted: Thu Dec 22, 2011 7:19 pm
Reply with quote

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

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Thu Dec 22, 2011 8:09 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 22, 2011 9:15 pm
Reply with quote

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

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Dec 22, 2011 9:20 pm
Reply with quote

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
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 Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
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