How to Convert Packed Decimal (PD) COMP-3 Fields to Zoned Decimal Field using DFSORT

Sometimes it is needed to convert packed decimal fields to numeric Or display formats for debugging or analysis purposes. Using DFSORT OUTREC options you can achieve the same.

Keyword Explanation

OUTREC: Tells SORT what part of input file to be put in output file.
PD: Input format in Packed Decimal
TO=ZDF: output format to be in all numerics
TO=ZD: output format to be in all numerics with an alphabet
LENGTH=n: If you want to override the output length, specify as n.

Example

Say you have an input file with below packed data as HEX. This represents a number +6150000 with picture clause of S9(7) COMP-3.

1----5----10
1300
200C

The actual representation which we want is:

1230000

To achieve this, the SYSIN of SORT should be:

SORT FIELD=COPY
OUTREC FIELDS=(1,4,PD,TO=ZDF)

If you run the JOB, the output would be:

1230000

Filed under:

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version