I want to use SYNCSORT to force all Packed Decimal fields to a negative sign value. The critical requirement is the 2nd nibble must be Hex 'D'. I have a method that works but it seems much too complex. In keeping with the KISS principle, I'm hoping someone has a better method. Perhaps using a bit mask on the last 4 bits? Here is the code I have come up with. Is there a better way?
* * This sort logic is intended to force all Packed Decimal amounts to * have a negative sign with a B'....1101' value (Hex 'xD'). * SORT FIELDS=COPY OUTFIL FILES=1, INCLUDE=(8,1,BI,NE,B'....1..1',OR, * POSITIVE PACKED DECIMAL 8,1,BI,EQ,B'....1111'), * UNSIGNED PACKED DECIMAL OUTREC=(1:1,7, * INCLUDING +0 8:(-1,MUL,8,1,PD),PD,LENGTH=1, 9:9,72) OUTFIL FILES=2, INCLUDE=(8,1,BI,EQ,B'....1..1',AND, * NEGATIVE PACKED DECIMAL 8,1,BI,NE,B'....1111'), * NOT UNSIGNED PACKED DECIMAL OUTREC=(1:1,7, * INCLUDING -0 8:(+1,MUL,8,1,PD),PD,LENGTH=1, 9:9,72)
In the code that processes the VSAM file, can you change the read logic to GET with KEY GTEQ and check for < 0 on the result instead of doing a specific keyed read?
If you did that, you could accept all three negative packed values xA, xB and xD.