0

I have a requirement to convert numeric data (stored as character on input) to either packed signed or packed unsigned formats. I can convert to packed/signed using the "PD" format, but I'm having a difficult time getting unsigned packed data.

For instance, I need a ZD number like 14723 converted to:

042

173

Using PD, I get this (which is fine):

0173

042C

Any suggestions? We do not have COBOL at this shop and are relying on SyncSort to handle these data conversions. I'm not seeing a "PK" option in SyncSort, but I've missed things before!

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47

1 Answers1

0

So you don't want a packed-decimal, which always has a sign (even when F for unsigned) in the low-order half-byte. You want Binary Coded Decimal (BCD).

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=* 
//SORTOUT  DD SYSOUT=* 
//SYSIN    DD * 
  OPTION COPY 

  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1,5,ZD,MUL,+10,TO=PD,LENGTH=4)),
        IFTHEN=(WHEN=INIT,BUILD=(1,3)) 
//SORTIN   DD * 
14723 

Will give you, in vertical hex:

042
173

To use an existing BCD, look at field-type PD0.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47