Monday, September 26, 2011

SORT : Convert zoned decimal to packed decimal

Problem
I am having a file in which a particular column is in Zoned decimal. In my  output I want to store the same in packed decimal. My input file length is 9(4)  and the output should be in 9(4) comp-3.  


Solution
Lets assume that both fields are not signed. Assuming the field is at the end of the record structure, all we have to do is:

//SYSIN DD *
 SORT FIELDS=COPY
 OUTREC FIELDS=(1,80,                 * First 80 bytes kept as such
                81,4,ZD,PD,LENGTH=3)  * Numeric converted to packed decimal

Note that this conversion will cause a change in record length, as 9(04) occupies 4 bytes and 9(04) COMP-3 occupies just 3 bytes. I hope that is the requirement.

Now, if you have got a signed zoned decimal, it is not as easy as this. However, Nothing is Impossible!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.