Page 1 of 1
How can we change the sign using SORT?
Posted: Thu Jul 24, 2014 5:11 pm
by Hari Om
Hi,
How can we change the sign of a Packed decimal field using SORT ? Can we multiply by -1 or is there any other solution to this?
The details are as follows: LRECL=500, field size is 8 bytes: S9(10)V9(5) comp-3. And position of the field=15.
Please help.
Re: How can we change the sign using SORT?
Posted: Thu Jul 24, 2014 8:24 pm
by William Collins
I'd subtract it from zero. You have to tell SORT the size and type of the result. Yes, you can multiply by -1.
Re: How can we change the sign using SORT?
Posted: Mon Jul 28, 2014 2:07 pm
by Hari Om
Thanks William. I've used the following. Please if it's correct or is there a better way of doing it:
Code: Select all
OPTION COPY
INREC IFTHEN=(WHEN=(15,8,PD,LT,0),
OVERLAY=(15:15,8,PD,MUL,-1,TO=PD,LENGTH=8))
How do you do it using subtraction?
Code: Select all
OPTION COPY
INREC IFTHEN=(WHEN=(15,8,PD,LT,0),
OVERLAY=(15:15,8,??,SUB,??...))
Re: How can we change the sign using SORT?
Posted: Thu Jul 31, 2014 12:39 pm
by Hari Om
William Collins wrote:I'd subtract it from zero. You have to tell SORT the size and type of the result. Yes, you can multiply by -1.
Hi William,
Could you please help me in knowing how would you substract from zero using SORT statements? I'm trying to figure it out but did not get it.
Code: Select all
OPTION COPY
INREC IFTHEN=(WHEN=(15,8,PD,LT,0),
OVERLAY=(15:15,8,??,SUB,??...))