Nope, I'm not going to do a Rumsfeld. :-)
But there are a couple of things I didn't know (I didn't know) about DFSORT. Relating them to you is probably OK because
- It's not something I'm embarrassed about.:-)
- If you want to understand some of the funkier new DFSORT tricks you probably need to know these things.
Consider these DFSORT examples (which I take no credit for). They are used to deal with groups of records and rely on features introduced about a year ago (with New Function APAR UQ95214 /UQ95213).
Here are the two things you need to know if you are ever to understand these examples...
OVERLAY items are applied in sequence
By this I mean that the first field specified is overlain first, then the second, then the third, etc... Now, the significance of this (and the reason for the bold emphasis) is that the result of the first overlaying can be used in the second overlaying. Consider the following fragment from the first example (here):
IFTHEN=(WHEN=NONE, OVERLAY=(152:SEQNUM,8,ZD, 144:144,8,ZD,SUB,152,8,ZD,M11,LENGTH=8))
Here's how we process this instruction (ignoring the WHEN=NONE IFTHEN piece):
- We overlay positions 152-159 with a DFSORT-generated record sequence number (and more on that later in this entry).
- We overlay positions 144-151 with the current value in 144-151 minus the just-generated value in 152-159 (not whatever was in 152-159 before we started OVERLAYing).
And this turns out to be critical to the way this smart trick works.
Every IFTHEN stage that uses SEQNUM has it's own separately-incremented SEQNUM counter
Consider the whole IFTHEN pipeline in the smart trick:
INREC IFTHEN=(WHEN=INIT,OVERLAY=(144:SEQNUM,8,ZD)), 1 IFTHEN=(WHEN=(2,4,CH,EQ,C'RPT.'), OVERLAY=(134:2,10,144:SEQNUM,8,ZD)), 2 IFTHEN=(WHEN=NONE, OVERLAY=(152:SEQNUM,8,ZD, 3 144:144,8,ZD,SUB,152,8,ZD,M11,LENGTH=8))
Each of these SEQNUMs, as I say, is a separately-incremented counter: If the WHEN condition is satisfied the OVERLAY (or BUILD) processing is performed on the record. And each SEQNUM counter is incremented...
- This one is applied to every record so is the true count of the records that INREC processed.
- This one is incremented only if (2,4,CH,EQ,C'RPT.') evaluates to true.
- This one is incremented if no other IFTHEN condition (other than WHEN=INIT conditions) is satisfied, that is if (2,4,CH,EQ,C'RPT.') evaluates to false.
Here are some other things you might not know about SEQNUM...
- For a long time now you've been able to specify a starting value and an increment. e.g.
OUTREC BUILD=( ... ,SEQNUM,8,ZD,START=5,INCR=5, ... )creates a sequence number that starts at 5 and goes up by 5 each time it's incremented (i.e for each record it's applied to.
- With UQ92514 / UQ92513 you can specify a RESTART subparameter. e.g.
INREC OVERLAY=(1:SEQNUM,8,ZD,RESTART=(16,8))restarts the sequence number at 1 each time the value in positions 16-23 changes.
- You can sort on a sequence number - to preserve the original sequence of records, perhaps. e.g.
INREC FIELDS=(SEQNUM,8,PD, ... )SORT FIELDS=(1,8,PD,A)
- You can perform arithmetic on a SEQNUM field - assuming you have the arithmetic expression support built into APAR UQ90053. Now, I will take credit for suggesting that MOD be supported so that sequence numbers could be written 1, 2, 3, 1, 2, 3, ... (That might allow you to subsequently separate neigbouring records by sorting on this
MODed sequence number, for example.) e.g.
INREC FIELDS=(SEQNUM,8,PD,MOD,+3, ... )SORT FIELDS=(1,8,PD,A)
- Not only does each stage in an IFTHEN pipeline have its own SEQNUM counter but INREC, OUTREC and each OUTFIL statement all have their counter (or, for IFTHEN, set of counters).
So, lots more flexibility with sequence numbers than you might imagine.