00001234 ERROR1 TYPE OF ERROR
00001234 ERROR ABOUT
00001234 TYPE2
ERROR FIELD
00001234 ERROR DESCRIPTION
00001234 DESC ENDED
00004567 TYPEN2 TYPE OF ERROR
00004567 ERROR NAME
TYPE3
00004567 DESC ENDED
TEST END
99999999
00001234 ERROR ABOUT
00001234 TYPE2
ERROR FIELD
00001234 ERROR DESCRIPTION
00001234 DESC ENDED
00004567 TYPEN2 TYPE OF ERROR
00004567 ERROR NAME
TYPE3
00004567 DESC ENDED
TEST END
99999999
I have then used these:
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(61:SEQNUM,8,ZD,
RESTART=(1,8))),
IFTHEN=(WHEN=GROUP,
BEGIN=(61,8,CH,EQ,C'00000001',
AND,1,8,CH,NE,C' '),
PUSH=(71:1,8)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,8,CH,EQ,C' '),
RECORDS=2,PUSH=(81:1,60,71,8))
PUSH=(81:1,60,71,8))
OVERLAY=(61:SEQNUM,8,ZD,
RESTART=(1,8))),
IFTHEN=(WHEN=GROUP,
BEGIN=(61,8,CH,EQ,C'00000001',
AND,1,8,CH,NE,C' '),
PUSH=(71:1,8)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,8,CH,EQ,C' '),
RECORDS=2,PUSH=(81:1,60,71,8))
PUSH=(81:1,60,71,8))
I suggest you run the first and second IFTHENs and see the effects, then run all three.
Then two tasks remain. To remove the records with blanks in the key, and insert, under two different conditions, the new records from those records - one lot now has a key, where bounded by records with a key, and the others do not.
OUTFIL OMIT=(1,8,CH,EQ,C' '),
IFTHEN=(WHEN=(61,8,CH,EQ,C'00000001',
AND,81,60,CH,NE,C' ',
AND,1,8,CH,EQ,141,8,CH),
BUILD=(71,8,89,52,/,
1,60)),
IFTHEN=(WHEN=(61,8,CH,EQ,C'00000001',
AND,81,60,CH,NE,C' ',
AND,1,8,CH,NE,141,8,CH),
BUILD=(81,60,/,
1,60)),
IFTHEN=(WHEN=NONE,BUILD=(1,60))
IFTHEN=(WHEN=(61,8,CH,EQ,C'00000001',
AND,81,60,CH,NE,C' ',
AND,1,8,CH,EQ,141,8,CH),
BUILD=(71,8,89,52,/,
1,60)),
IFTHEN=(WHEN=(61,8,CH,EQ,C'00000001',
AND,81,60,CH,NE,C' ',
AND,1,8,CH,NE,141,8,CH),
BUILD=(81,60,/,
1,60)),
IFTHEN=(WHEN=NONE,BUILD=(1,60))
The final IFTHEN is for all records not preceded by a blank key.
This is, lightly, tested with DFSORT.
If you have multiple contiguous blank keys, this will not work.
The output is:
00001234 ERROR1 TYPE OF ERROR
00001234 ERROR ABOUT
00001234 TYPE2
00001234 ERROR FIELD
00001234 ERROR DESCRIPTION
00001234 DESC ENDED
00004567 TYPEN2 TYPE OF ERROR
00004567 ERROR NAME
00004567 TYPE3
00004567 DESC ENDED
TEST END
99999999
00001234 ERROR ABOUT
00001234 TYPE2
00001234 ERROR FIELD
00001234 ERROR DESCRIPTION
00001234 DESC ENDED
00004567 TYPEN2 TYPE OF ERROR
00004567 ERROR NAME
00004567 TYPE3
00004567 DESC ENDED
TEST END
99999999