To fetch records ageing more than 15 years using DFSORT
Posted: Tue Jan 31, 2017 5:16 pm
Hello There,
I got this requirement to retrieve records more than 15 years old. And have written the following DFSORT card but it is not fetching the desire result.
Please could anyone suggest what’s wrong.
//STEP001 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0001 REC1-991201
0002 REC2-091231
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
BUILD=(01:01,04,
06:DATE1,
15:06,12)),
IFTHEN=(WHEN=INIT,
OVERLAY=(06:06,08,Y4T,SUBYEARS,+15,TOGREG=Y2T,2X))
SORT FIELDS=COPY
INCLUDE COND=(20,06,LT,06,06),FORMAT=Y2T
/*
The “date” field in the SORTIN card is in the format YYMMDD; starting at 11th position.
I’m getting the following result
0001 020131 REC1-991201
0002 020131 REC2-091231
While the desired result is only the first record as it refers to year 1999.
0001 020131 REC1-991201
Thanking you in anticipation.
I got this requirement to retrieve records more than 15 years old. And have written the following DFSORT card but it is not fetching the desire result.
Please could anyone suggest what’s wrong.
//STEP001 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0001 REC1-991201
0002 REC2-091231
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
BUILD=(01:01,04,
06:DATE1,
15:06,12)),
IFTHEN=(WHEN=INIT,
OVERLAY=(06:06,08,Y4T,SUBYEARS,+15,TOGREG=Y2T,2X))
SORT FIELDS=COPY
INCLUDE COND=(20,06,LT,06,06),FORMAT=Y2T
/*
The “date” field in the SORTIN card is in the format YYMMDD; starting at 11th position.
I’m getting the following result
0001 020131 REC1-991201
0002 020131 REC2-091231
While the desired result is only the first record as it refers to year 1999.
0001 020131 REC1-991201
Thanking you in anticipation.