Page 1 of 1

Multiplication using Constant

PostPosted: Wed May 12, 2010 8:37 pm
by mainframe_novice
Hi,

Is it possible to do the multiplication within SyncSort using Constant

I have following File

Customer_Id  Balance
A0001           12300.00
A0002           400.00


Customer Id position 1-4
Balance Position 5-13

In output I want Balance multiplied by -1 as I want to make it as a negative Balance

Customer_Id  Balance
A0001           -12300.00
A0002              -400.00

Re: Multiplication using Constant

PostPosted: Wed May 12, 2010 9:44 pm
by Alissa Margulies
Hello mainframe_novice.

Are the Balance fields left or right justified?
Are the starting values all positive or are some already negative values?
Which release of Syncsort are you running?

Regards,

Re: Multiplication using Constant

PostPosted: Thu May 13, 2010 1:27 am
by mainframe_novice
Input file has only positive records
version is 1.3.2
balance is right justified

Re: Multiplication using Constant

PostPosted: Thu May 13, 2010 11:23 pm
by Alissa Margulies
If all you are doing is inserting a negative sign, then you can use this SyncSort for z/OS 1.3 job:
//SORT1 EXEC PGM=SORT                                         
//SORTIN  DD *                               
0001 12300.00                               
0002   400.00                               
//SORTOUT DD SYSOUT=*                       
//SYSOUT  DD SYSOUT=*                       
//SYSIN   DD *       
   SORT FIELDS=COPY                         
   OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,4,C'-',5,9)),
          IFTHEN=(WHEN=INIT,BUILD=(1,4,5,10,SQZ=(SHIFT=RIGHT)))
/*                   

Here is the output produced:
0001 -12300.00
0002   -400.00

Re: Multiplication using Constant

PostPosted: Fri May 14, 2010 1:17 am
by mainframe_novice
Thanks Alissa !

That works .

Re: Multiplication using Constant

PostPosted: Fri Jun 11, 2010 12:25 am
by mainframe_novice
I was trying to multiply the zoned decimal number with -1 and was never succesful .

Since I have multiple fields like these in my file , I prefer multiply by -1 rather than putting '-' and shifting fields positions for each time .

Even substracting a number from 0 will work .

Can you please put a syncsort example for multiplication

My failed attempts involved following
multiplication:-
5,9,zd,mul,-1,zd

subtraction:-
0,zd,sub,5,9,zd

Thanks

Re: Multiplication using Constant

PostPosted: Fri Jun 11, 2010 1:08 am
by dick scherrer
Hello,

The fields are not zoned-decimal (ZD). . .

Try UFF. I don't have a way to test or i'd post a working sample.

Re: Multiplication using Constant

PostPosted: Fri Jun 11, 2010 1:35 am
by mainframe_novice
Excellent !
Thanks Dick .
It worked .

I had to put ,M4 since thec sign was displayed at the end .
Also need to restrict it's length by putting ,LENGTH=9 as I found the length was expanded .

Thanks again for your help !

Re: Multiplication using Constant

PostPosted: Fri Jun 11, 2010 1:58 am
by dick scherrer
You're welcome - thank you for letting us know it is working :)

d