View previous topic :: View next topic
|
Author |
Message |
Hemant L
New User
Joined: 07 Feb 2020 Posts: 2 Location: usa
|
|
|
|
Hi
I am trying to add 2 fields from the same record and store the result in another position on the same record. Example
field1 in pos 1 and field2 in pos 20, sum the 2 fields and store the result in pos 30
fld1 fld2 fld3 (result - sum of fld1 + fld2)
123.23 45.00 168.23
Please let me know how this can be accomplished with syncsort.
Thank you. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Firstly by posting in the Syncsort part of the forum - topic moved.
Secondly - what have you tried?
Thirdly - sorts tend to know nothing about decimals so you need to multiply by 100 beffor adding then divide the sum by 100 (I believe - search the DFSort and Syncsort forums for topics realted to this). |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
Back to top |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
Curiosity - why store sum when it can be calculated at will? |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1341 Location: Bamberg, Germany
|
|
|
|
Let's see what has been tried and what Data formats to expect. Are fixed or floating point decimals used. Negative values and so on. |
|
Back to top |
|
|
Hemant L
New User
Joined: 07 Feb 2020 Posts: 2 Location: usa
|
|
|
|
Thank you all for the responses and for pointing me in the right direction.
I was actually trying to add 2 packed fields and store the result in another packed field.
Input shown as packed
Code: |
----+----1----+----2---
22244444111444444444444
22C0000011C000000000000
-----------------------
33344444111444444444444
33D0000011D000000000000 |
Code: |
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(18:1,3,PD,ADD,9,3,PD,PD,LENGTH=5)
/* |
Result
Code: |
2224444411144444400333444
22C0000011C0000000033C000
------------------------
(
3334444411144444400444444
33D0000011D0000000044D000 |
Thank you
H |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2147 Location: USA
|
|
|
|
Hemant L wrote: |
Thank you all for the responses and for pointing me in the right direction.
I was actually trying to add 2 packed fields and store the result in another packed field.
Input shown as packed
Code: |
----+----1----+----2---
22244444111444444444444
22C0000011C000000000000
-----------------------
33344444111444444444444
33D0000011D000000000000
|
Code: |
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(18:1,3,PD,ADD,9,3,PD,PD,LENGTH=5)
/* |
Result
Code: |
2224444411144444400333444
22C0000011C0000000033C000
------------------------
(
3334444411144444400444444
33D0000011D0000000044D000 |
Thank you
H |
22222+11111=000033333
(-33333)+(-11111)=(-000044444)
What is not acceptable??? |
|
Back to top |
|
|
|