Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/10)
//SORTOUT DD DSN=... output file (FB/10)
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=10,
IFTHEN=(WHEN=INIT,BUILD=(8C'0',9:9,2,11:1,1)),
IFTHEN=(WHEN=(11,1,BI,BO,X'80'),OVERLAY=(1:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'40'),OVERLAY=(2:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'20'),OVERLAY=(3:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'10'),OVERLAY=(4:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'08'),OVERLAY=(5:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'04'),OVERLAY=(6:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'02'),OVERLAY=(7:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(11,1,BI,BO,X'01'),OVERLAY=(8:C'1'))
An explanation then.
There is a 10-byte input record, of which only three bytes are significant (for the original TS/OP). These are bytes 1, and 9/10.
What is required for the output is the bit-pattern of byte 1, in character format. This must be in the first eight bytes of the output. Bytes 9/10 are also required, unchanged, in the output.
IFOUTLEN sets the length of the records for when all IFTHEN processing is complete. It is set to 10.
The BUILD makes a new record consisting of eight zeros, bytes 9/10 and byte 1, now moved to byte 11.
Byte 11 is then interrogated, bit by bit, and the corresponding byte from 1-8 is set to C'1' if the bit is on.
The HIT=NEXT is because otherwise the IFTHEN processing will stop, as it normally does once a record has matched an IFTHEN=(WHEN=(logical expression).
When all the IFTHENs are processed, the excess 11th byte is dropped off due to the IFOUTLEN having set the length to 10.
This will work, but is perhaps overcomplicated for what you need, due to the relocation of the byte being converted.
Exactly how to apply it in your case, we don't know. If you still have a problem, post your actual requirement, with sample input and expected output and what you have tired.