IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Accumulating fields using syncsort


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Hemant L

New User


Joined: 07 Feb 2020
Posts: 2
Location: usa

PostPosted: Fri Feb 07, 2020 2:55 am
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2448
Location: Hampshire, UK

PostPosted: Fri Feb 07, 2020 4:36 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Fri Feb 07, 2020 6:33 am
Reply with quote

ibmmainframes.com/about49323.html
ibmmainframes.com/viewtopic.php?p=240304#240304
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 318
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Fri Feb 07, 2020 7:37 am
Reply with quote

Curiosity - why store sum when it can be calculated at will?
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 385
Location: Bamberg, Germany

PostPosted: Fri Feb 07, 2020 10:37 am
Reply with quote

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
View user's profile Send private message
Hemant L

New User


Joined: 07 Feb 2020
Posts: 2
Location: usa

PostPosted: Fri Feb 07, 2020 8:17 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 924
Location: Maryland

PostPosted: Fri Feb 07, 2020 11:53 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Last day of the month via SYNCSORT. SYNCSORT 5
No new posts Break a record into fields, each fiel... SYNCSORT 2
No new posts SYNCSORT Error - CONTROL FIELD BEYOND... SYNCSORT 10
No new posts FIELDS OVERLAPPING WITH MODE = IN OR ... CICS 3
No new posts Populating Date and Sequence numer in... SYNCSORT 11
Search our Forums:

Back to Top