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: 2455
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: 3051
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: 419
Location: Inside the SPEW (Southwest Ohio, 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

Senior Member


Joined: 15 Aug 2015
Posts: 1243
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

Senior Member


Joined: 29 Apr 2008
Posts: 2017
Location: USA

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 Compare only first records of the fil... SYNCSORT 7
No new posts Count Records with a crietaria in a f... DFSORT/ICETOOL 5
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts DFSORT/SYNCSORT/ICETOOL JCL & VSAM 8
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top