Convert two PD fields to Numeric using Sort



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Convert two PD fields to Numeric using Sort

Postby Kitz » Wed Nov 04, 2015 4:09 am

Hi there,

I have two packed decimal fields in a file of record length 80
Field1 1-4 (S9(7) COMP-3)
Field2 5-9 (S9(9) COMP-3)

I tried to do with the below, but the results are not as expected.
INREC BUILD=(1,9,PD,TO=ZD,LENGTH=16

Could you please advise how do I convert the data to numeric using SORT?
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: Convert two PD fields to Numeric using Sort

 

Re: Convert two PD fields to Numeric using Sort

Postby Robert Sample » Wed Nov 04, 2015 4:38 am

Treat them as separate fields. Your INREC is attempting to use the first field's sign bits as data, which will give erroneous results at best.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: Convert two PD fields to Numeric using Sort

Postby BillyBoyo » Wed Nov 04, 2015 5:26 am

As Robert says, something like this;

 INREC BUILD=(1,4,PD,TO=ZD,LENGTH=7,5,5,TO=ZD,LENGTH=9)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Convert two PD fields to Numeric using Sort

Postby Kitz » Thu Nov 05, 2015 3:35 am

Thanks a lot Billy Boya. I am able to convert the file to numeric now.

For some reasons, these fields are coming with a prefix '0' to each field.
1.Could you please advise how to I get rid of '0' to these fields?
2. Also, pls let me know how to I get a space in between these two fields in the output file.

Current file:
0111111011111111
0222222022222222
0121212014345678

Expected output:
111111 11111111
222222 22222222
121212 14345678
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: Convert two PD fields to Numeric using Sort

Postby BillyBoyo » Thu Nov 05, 2015 4:51 am

Change both the LENGTH=s. Use X between the fields to insert one blank (2X to insert two blanks).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Convert two PD fields to Numeric using Sort

Postby Terry Heinze » Thu Nov 05, 2015 8:02 pm

Kitz,
In the future, please use code tags to indicate spacing:
Current file:
0111111011111111
0222222022222222
0121212014345678

Expected output:
111111 11111111
222222 22222222
121212 14345678
.... Terry
Terry Heinze
 
Posts: 193
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 10 times
Been thanked: 11 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post