Joined: 17 Dec 2002 Posts: 17 Topics: 2 Location: NJ, USA
Posted: Mon Apr 06, 2020 4:49 pm Post subject: Convert CSL format data to zoned decimal
We had a need to convert the values in a field from CSL (character with a leading sign) format to zoned decimal. I checked the SORT manual but I didn't see an example there on how to do this. I coded an ICETOOL step that did the conversion using 2 passes thru the data.
For the future, is anyone aware of a way to perform the conversion in 1 pass thru the data?
The record length is 278 bytes. The field in question appears in bytes 142-152. This is how the input data looks:
The sign appears in byte 142, the numeric value appears in bytes 143-152.
Pass 1 removed the decimal point at byte 150 by moving the data from bytes 143-149 to bytes 144-150 and placing a zero in byte 143.
Pass 2 tested the sign in byte 142. If the sign is +, it multiplied the value in bytes 143-152 by +1 and placed the result in zoned decimal format in bytes 143-152. If the sign is -, it multiplied the value in bytes 143-152 by -1 and placed the result in zoned decimal format in bytes 143-152.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Mon Apr 06, 2020 6:10 pm Post subject:
Spolacek,
It is quite simple and you don't even need 2 passes of data. All you need is use SFF format to convert it to ZD. Try this. I replaced the 142 byte also. I also removed the DCB parm in the JCL as DFSORT will automatically calculate it based on the INPUT/Control cards.
The Output at position 142 will be as follows for the sample input data provided
Code:
0000000240}
00000000600
00000001600
If you really want to test you can just build the input field and get the target field using the following control cards
Code:
//SYSIN DD *
OPTION COPY
INREC BUILD=(142,11, $ CSL FIELD
X, $ SPACE
142,11,SFF,ZD,LENGTH=11) $ ZD FIELD
/*
PS: With ICETOOL SYSIN, SORTCNTL, SORTIN, SORTOUT, SORTINnn, and xxxxINnn (where xxxx is specified in a USING operand) should not be used as ddnames in ICETOOL operators nor supplied as DD statements.
This is documented in the restrictions for ICETOOL
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum