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

Increase Transparency and Collaboration Product Backlog

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

3 weeks ago

Product Backlog – Incremental value to the customer

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

4 weeks ago

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

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

4 weeks ago

PAL-EBM Professional Agile Leadership – EBM Certification

The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…

4 months ago

PAL I Professional Agile Leadership Certification

The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…

4 months ago

Scrum Master Certification: CSM, PSM, SSM

Choosing the right Scrum Master Certification depends on your current experience and career goals. If…

6 months ago