Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK. This is a good example of the time wasted when the requirement is not fully described.
Your current control cards are not working because the HEADER1 is relying on the content of the first record output, and there isn't a first record output when there are no records.
Then, when adding JOIN UNPAIRED,F2 to get the dummies-matching-no-data the TRAILER, which is counting the records, no longer works as-is.
So, we have to make some extensive changes.
The header is now written not by HEADER1 but by using the / (slash operator) it is written before the first actual record. This requires the addition of a sequence number then tested for one. The unmatched dummy record also causes the header to be written, but with no dummy record written (obviously). The TRAILER1 is amended to make use of the count from the "header" which is on all the REFORMAT records via the processing in the JNF2CNTL.
The JNF2CNTL is amended to include a GROUP with only one record, which identifies the DUMMY records and takes the 0 mentioned below and PUSHes it over the 1 set by the WHEN=INIT so that the dummy records are not counted when it comes to the SUM.
The DUMMY records are to look something like this, single records with the A1, A2 and A3 starting in column 79:
Code: |
DUMMY RECORD COUNT TO BE 0 (ZERO) A1
DUMMY RECORD COUNT TO BE 0 (ZERO) A2
DUMMY RECORD COUNT TO BE 0 (ZERO) A3
|
The 0 in the above is used, so if the position of the 0 is changed, you have to make the code reflect that.
It has been lightly tested. First make sure you understand it and that it meets all your requirements. Then test it thoroughly. Then enjoy applying the changes for 50 OUTFILs and testing it thoroughly again (lots of scope for typos/editos).
Code: |
OPTION COPY
JOINKEYS F1=INA,FIELDS=(79,2,A)
JOINKEYS F2=INB,FIELDS=(79,2,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F1:1,80,F2:1,88,?)
INREC OVERLAY=(105:161,8)
OUTFIL FNAMES=A1,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A1',
OR,(169,1,CH,EQ,C'2',
AND,159,2,CH,EQ,C'A1')),
TRAILER1=('TRAILER',105,8),
IFTHEN=(WHEN=INIT,OVERLAY=(170:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(169,1,CH,EQ,C'2'),
BUILD=(81,78)),
IFTHEN=(WHEN=(170,8,ZD,EQ,1),
BUILD=(81,78,/,1,78)),
IFTHEN=(WHEN=NONE,
BUILD=(1,78))
OUTFIL FNAMES=A2,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A2',
OR,(169,1,CH,EQ,C'2',
AND,159,2,CH,EQ,C'A2')),
TRAILER1=('TRAILER',105,8),
IFTHEN=(WHEN=INIT,OVERLAY=(170:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(169,1,CH,EQ,C'2'),
BUILD=(81,78)),
IFTHEN=(WHEN=(170,8,ZD,EQ,1),
BUILD=(81,78,/,1,78)),
IFTHEN=(WHEN=NONE,
BUILD=(1,78))
OUTFIL FNAMES=A3,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A3',
OR,(169,1,CH,EQ,C'2',
AND,159,2,CH,EQ,C'A3')),
IFTHEN=(WHEN=INIT,OVERLAY=(170:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(169,1,CH,EQ,C'2'),
BUILD=(81,78)),
IFTHEN=(WHEN=(170,8,ZD,EQ,1),
BUILD=(81,78,/,1,78)),
IFTHEN=(WHEN=NONE,
BUILD=(1,78))
//*
//JNF1CNTL DD *
OMIT COND=(1,6,CH,EQ,C'HEADER',OR,1,7,CH,EQ,C'TRAILER')
//*
//JNF2CNTL DD *
OMIT COND=(1,7,CH,EQ,C'TRAILER')
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:7C'0',C'1')),
IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'DUMMY '),RECORDS=1,
PUSH=(88:26,1)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),PUSH=(1,78))
SUM FIELDS=(81,8,ZD)
|
|
|