I am trying to rearrange a file, which includes building a new header from the old header and converting dates, rearranging the data lines and rebuilding a trailer record with a converted date from the original header.
I can get it to work in bits and I can get it all to work in three steps but I'm sure it should work in single step. I'm having trouble combining the BUILD, OVERLAY, PARSE in subsequent IFTHENs, Even with the HIT=NEXT option it is still ignoring certain conditions. The example below is my latest attempt where I combined some of the BUILD, OVERLAY, PARSE statements but I have found out that this is not allowed. As this non-working example is the most concise of my non-working attempts, I will include it as a guide to what I'm trying to do.
The example below gives the input and output of what I'm trying to achieve in a single step.
//STEP10 EXEC PGM=SORT
//*
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//SORTIN DD *
VOL1JJJJJJ 333333
HDR1NNNNNNN DDEX 00010001 15162 ZZZZZ 000000
HDR2NNNNNNNNNNN 00
UHL1 44444444444 000000004 SULTI 001
111111AAAAAAAAXXXXXXXXXXXXXXXXXXXXX00000000011YYYYYYYYYYYYYYYYYYYYYYYYYY
222222BBBBBBBBXXXXXXXXXXXXXXXXXXXXX00000000022YYYYYYYYYYYYYYYYYYYYYYYYYY
333333CCCCCCCCXXXXXXXXXXXXXXXXXXXXX00000000033ZZZZZZZZZZZZZZZZZZZZZZZZZZ
EOF15555555 FFFF 00007777 08888 19999 000000
EOF2GGGGGGGGGGG 00
UTL10000000030246000000003024600000020000001 0000000
//*
//SORTOUT DD DSN=MYSORT.OUT
//*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OMIT COND=((01,03,CH,EQ,C'VOL'),OR, -- EXCLUDE THE HEADERS AND
(01,04,CH,EQ,C'HDR2'),OR, -- TRAILERS EXCEPT HDR1
(01,03,CH,EQ,C'UHL'),OR, --
(01,03,CH,EQ,C'EOF'),OR, --
(01,03,CH,EQ,C'UTL')) --
* REBUILD SINGLE HEADER
INREC IFTHEN=(WHEN=(01,04,CH,EQ,C'HDR1'),
BUILD=(14C'0', -- 14 ZEROS
DATENS=(4MD), -- SYSTEM DATE YYYYMMDD
43,05,Y2T,TOGREG=Y4T, -- CONVERT BULK DATE FROM
C'MORETEXT', -- Y2T=YYDDD TO Y4T=YYYYMMDD
62C' '), -- 62 SPACES
PARSE=(%01=(ABSPOS=43,FIXLEN=5))), -- SAVE OFF BULK DATE
* IDENTIFY THE DATA RECORDS
IFTHEN=(WHEN=((01,03,CH,NE,C'VOL'),AND, -- IDENTIFY DATA RECS
(01,03,CH,NE,C'HDR'),AND, --
(01,03,CH,NE,C'UHL'),AND, --
(01,03,CH,NE,C'EOF'),AND, --
(01,03,CH,NE,C'UTL')), --
BUILD=(01,06,
07,08,
36,11,
75C' '),
OVERLAY=(101:36,11))
* BUILD NEW TRAILER WITH CONVERTED BULK DATE AND TOTALS
OUTFIL REMOVECC,
TRAILER1=(14C'0',
DATENS=(4MD),
%01,Y2T,TOGREG=Y4T,
'MORETEXT',
' ',
TOT=(101,11,ZD,M11,LENGTH=15),
41C' ')
//*
//*
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//SORTIN DD *
VOL1JJJJJJ 333333
HDR1NNNNNNN DDEX 00010001 15162 ZZZZZ 000000
HDR2NNNNNNNNNNN 00
UHL1 44444444444 000000004 SULTI 001
111111AAAAAAAAXXXXXXXXXXXXXXXXXXXXX00000000011YYYYYYYYYYYYYYYYYYYYYYYYYY
222222BBBBBBBBXXXXXXXXXXXXXXXXXXXXX00000000022YYYYYYYYYYYYYYYYYYYYYYYYYY
333333CCCCCCCCXXXXXXXXXXXXXXXXXXXXX00000000033ZZZZZZZZZZZZZZZZZZZZZZZZZZ
EOF15555555 FFFF 00007777 08888 19999 000000
EOF2GGGGGGGGGGG 00
UTL10000000030246000000003024600000020000001 0000000
//*
//SORTOUT DD DSN=MYSORT.OUT
//*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OMIT COND=((01,03,CH,EQ,C'VOL'),OR, -- EXCLUDE THE HEADERS AND
(01,04,CH,EQ,C'HDR2'),OR, -- TRAILERS EXCEPT HDR1
(01,03,CH,EQ,C'UHL'),OR, --
(01,03,CH,EQ,C'EOF'),OR, --
(01,03,CH,EQ,C'UTL')) --
* REBUILD SINGLE HEADER
INREC IFTHEN=(WHEN=(01,04,CH,EQ,C'HDR1'),
BUILD=(14C'0', -- 14 ZEROS
DATENS=(4MD), -- SYSTEM DATE YYYYMMDD
43,05,Y2T,TOGREG=Y4T, -- CONVERT BULK DATE FROM
C'MORETEXT', -- Y2T=YYDDD TO Y4T=YYYYMMDD
62C' '), -- 62 SPACES
PARSE=(%01=(ABSPOS=43,FIXLEN=5))), -- SAVE OFF BULK DATE
* IDENTIFY THE DATA RECORDS
IFTHEN=(WHEN=((01,03,CH,NE,C'VOL'),AND, -- IDENTIFY DATA RECS
(01,03,CH,NE,C'HDR'),AND, --
(01,03,CH,NE,C'UHL'),AND, --
(01,03,CH,NE,C'EOF'),AND, --
(01,03,CH,NE,C'UTL')), --
BUILD=(01,06,
07,08,
36,11,
75C' '),
OVERLAY=(101:36,11))
* BUILD NEW TRAILER WITH CONVERTED BULK DATE AND TOTALS
OUTFIL REMOVECC,
TRAILER1=(14C'0',
DATENS=(4MD),
%01,Y2T,TOGREG=Y4T,
'MORETEXT',
' ',
TOT=(101,11,ZD,M11,LENGTH=15),
41C' ')
//*
Input
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
VOL1JJJJJJ 333333
HDR1NNNNNNN DDEX 00010001 15162 ZZZZZ 000000
HDR2NNNNNNNNNNN 00
UHL1 44444444444 000000004 SULTI 001
111111AAAAAAAAXXXXXXXXXXXXXXXXXXXXX00000000011YYYYYYYYYYYYYYYYYYYYYYYYYY
222222BBBBBBBBXXXXXXXXXXXXXXXXXXXXX00000000022YYYYYYYYYYYYYYYYYYYYYYYYYY
333333CCCCCCCCXXXXXXXXXXXXXXXXXXXXX00000000033ZZZZZZZZZZZZZZZZZZZZZZZZZZ
EOF15555555 FFFF 00007777 08888 19999 000000
EOF2GGGGGGGGGGG 00
UTL10000000030246000000003024600000020000001 0000000
VOL1JJJJJJ 333333
HDR1NNNNNNN DDEX 00010001 15162 ZZZZZ 000000
HDR2NNNNNNNNNNN 00
UHL1 44444444444 000000004 SULTI 001
111111AAAAAAAAXXXXXXXXXXXXXXXXXXXXX00000000011YYYYYYYYYYYYYYYYYYYYYYYYYY
222222BBBBBBBBXXXXXXXXXXXXXXXXXXXXX00000000022YYYYYYYYYYYYYYYYYYYYYYYYYY
333333CCCCCCCCXXXXXXXXXXXXXXXXXXXXX00000000033ZZZZZZZZZZZZZZZZZZZZZZZZZZ
EOF15555555 FFFF 00007777 08888 19999 000000
EOF2GGGGGGGGGGG 00
UTL10000000030246000000003024600000020000001 0000000
Output detail:
Header
01-14 14 zeros
15-22 System date YYYYMMDD
23-30 Converted YYDDD date from pos 43 of input HDR1 line converted to YYYYMMDD
31 onwards text.
Trailer
01-14 14 nines
15-22 System date YYYYMMDD
23-30 Converted YYDDD date from pos 43 of input HDR1 line converted to YYYYMMDD
31-40 text
41-58 Sum of amount in detail input lines at pos 36-46
MYSORT.OUT
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
000000000000002015061520150611MORETEXT
111111AAAAAAAA00000000011
222222BBBBBBBB00000000022
333333CCCCCCCC00000000033
999999999999992015061520150611MORETEXT 000000000000000066
******************************** Bottom of Data ********************************
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
000000000000002015061520150611MORETEXT
111111AAAAAAAA00000000011
222222BBBBBBBB00000000022
333333CCCCCCCC00000000033
999999999999992015061520150611MORETEXT 000000000000000066
******************************** Bottom of Data ********************************
Any help much appreciated (I have read several PDF manuals).
I don't know why the Preview has added in blank lines ? .All the code was cut and pasted came from a 72 char wide mainframe screen. Hopefully you can still work what's going on.
Martin.