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

Optimize Outer Join Queries in the COBOL DB2 Program

Optimize Outer Join queries is a powerful tool for retrieving data from multiple tables. However,…

4 months ago

OUTER JOIN Queries: Common Errors and Resolutions

OUTER JOIN Queries are a valuable tool in SQL, allowing you to retrieve data from…

4 months ago

Impediments: Examples and Strategies for Scrum Masters

Mastering impediments is crucial to the Scrum Master's role in fostering a high-performing Scrum Team.…

4 months ago

Sprint Goal in Scrum with Examples

A Sprint Goal is a short, clear, and motivating target the Scrum Team aims to…

4 months ago

Context Switching – Measure and Avoid

Context switching refers to changing focus or shifting attention from one task or activity to…

5 months ago

Motivate People to Use Scrum – Strategies and Examples

Embracing change is never easy, especially when it involves a shift in work methodology. Motivate…

7 months ago