JCL

Convert Date DDMMMYY to MM/DD/YY Format

DFSORT doesn’t have a built-in function for Convert Date – interpreting the month field of date in DDMMMYY formats as numeric values but you can use INREC and OUTREC statements to translate the month back and forth. Let’s take an example assuming that the DDMMMYY date is in positions 1-7.

BUILD=(3,3, 
       3,3, 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'), 
        1,2,              —> DD
        6,2,              —> YY
        8,73)             —> 73 is length to end of record
SORT FIELDS=(4,6,Y2W,D)   —> Sort MMDDYY using Century Window 
OUTREC BUILD=(6,2,        —> DD 
              1,3,        —> MON 
              8,2,        —> YY 
              10,73)      —> Rest of record

You use p, m,CHANGE=(v,find,set,…) to give the position and length of the input field, the length of the output field, and the “table” consisting of pairs of find constants, and set constants or set fields. The result of CHANGE is 

 Jan | 01
 Feb | 02
 Mar | 03
 Apr | 04
 May | 05
 Jun | 06
 Jul | 07
 Aug | 08
 Sep | 09
 Oct | 10
 Nov | 11
 Dec | 12 

Example of Convert Date – DDMMMYY to MM/DD/YY Format

Concert input record’s date format from DD-MMM-YY (01-JAN-21) to MM/DD/YYYY (01/01/2021) using IFTHEN

//STEP0100 EXEC PGM=SORT     
 //SYSOUT   DD SYSOUT=*         
 //SORTIN   DD *              
 ----+----1----+----2----+----3----+----4----+----5
 XXXXXXXXXXXXXXXXX~01-JAN-21~XXXXXXXXXXX      
 //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(/)))     
 //*
Output: XXXXXXXXXXXXXXXXX~01-JAN-21~XXXXXXXXXXX01/01/21

SYNCSORT Manual: Click Here                 JCL Blogs: Click Here

Admin

Share
Published by
Admin

Recent Posts

Effective User Interviews in Scrum Framework

Effective User interviews play a crucial role in Scrum methodology, helping Product Owners and Scrum…

2 weeks ago

User Research Tools and Techniques for Product Owners

Product Owners should be well-versed in various user research tools and techniques to effectively understand…

2 weeks ago

Effective Product Owner in Agile Development

Effective Product Owner plays a crucial role in Agile development, acting as the bridge between…

2 weeks ago

Increase Transparency and Collaboration Product Backlog

A well-maintained product backlog is crucial for successful product development. It serves as a single…

2 months ago

Product Backlog – Incremental value to the customer

Incremental value to the customer refers to the gradual delivery of small, functional parts of…

3 months ago

Product Market, Customer’s Desire, Need, and Challenges

A Product Market refers to the group of potential customers who might be interested in…

3 months ago