I'm using the below SORT card in my first SORT step to select and modify the data.
Code: Select all
SORT FIELDS=COPY
INCLUDE COND=(116,8,CH,EQ,C'RUN DATE',OR,2,11,CH,EQ,C'GRAND TOTAL')
INREC IFTHEN=(WHEN=(2,11,CH,EQ,C'GRAND TOTAL'),
BUILD=(1:C'VALUE 1:',15:63,17)),
IFTHEN=(WHEN=(116,8,CH,EQ,C'RUN DATE'),
PARSE=(%00=(ABSPOS=126,FIXLEN=2),
%01=(ABSPOS=129,FIXLEN=2),
%02=(ABSPOS=132,FIXLEN=2)),
BUILD=(1:C'20',3:%02,5:%00,7:%01))
OUTREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(40:1,80))
OUTFIL STARTREC=2
****** ***************************** Top of Data **********
000001 VALUE 1: 10,228.32 20140501
****** **************************** Bottom of Data ********
Then i run a second SORT step to compare the modified RUN DATE with Current Date DATE1 and based on it i decide if the value needs to be kept or not. The second SORT card is
Code: Select all
INCLUDE COND=(1,5,CH,EQ,C'VALUE')
OUTREC IFTHEN=(WHEN=(40,8,CH,NE,DATE1),
OVERLAY=(15:C'DATE ERROR, COLLECT THE REPORT MANUALLY')),
IFTHEN=(WHEN=(40,8,CH,EQ,DATE1),
OVERLAY=(40:C' '))
SORT FIELDS=COPY
****** ***************************** Top of Data ********
000001 VALUE 1: 10,228.32
****** **************************** Bottom of Data ******
If they dont match, then the output becomes
****** ***************************** Top of Data ***************
000001 VALUE 1: DATE ERROR, COLLECT THE REPORT MANUALLY
****** **************************** Bottom of Data *************
Now this whole thing works only If my input file has only one record with keyword "GRAND TOTAL" in position 2,11, If there are multiple records then my records dont have RUN DATE at the end (except for Record1). I'm sure there must be a simple way to do this. Could someone point me in the right direction please. Please let me know if you need any more information. All files used are FB with an RC of 133. Is there a better way to compare dates, then may be set an RC if the RUN DATE and Current date dont match or a way to EDIT each record to contain the RUN DATE at the end of the each resulting records of the first output file. And can this be done with one SORT step instead of 2. My apologies if I'm overstating or over-elaborating the problem. Thanks in advance.