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

Need to get the SUM of two fields using SUM FIELDS only


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Tue Jun 18, 2019 1:27 pm
Reply with quote

Hello Everyone,

I am trying to calculate the SUM of two fields from the Input file using the SUM FIELDS option of DFSORT. The reason i am looking for SUM FIELDS option only is because part of my application was transferred to Linux and i will run this sort card on Linux and there no other option works except SUM FIELDS.

The sum of first field is working fine but i am getting the issue while summing the second field which is having the decimal value with sign. Below is the file layout :

Code:

----+----1----+----2----+----3----+----4---
********************************* Top of Da
001,"ALAOO","ACTUALS",119986,-0000000167.59
001,"ALAOO","ACTUALS",119986,-0000000186.04
001,"ALAOO","ACTUALS",119986,-0000001380.46
001,"ALAOO","ACTUALS",119986,-0000003265.91
001,"ALAOO","ACTUALS",119986, 0000000009.07
001,"ALAOO","ACTUALS",119986, 0000000023.56
001,"ALAOO","ACTUALS",119986, 0000000047.12
001,"ALAOO","ACTUALS",119986,-0000000004.98
001,"ALAOO","ACTUALS",119986,-0000000004.77


This is the SORT card which i have tried :
Code:
//SYSIN    DD *                                               
 SORT FIELDS=(6,5,CH,A)                                       
 SUM FIELDS=(1,3,ZD,30,14,ZD)                                 
 OUTREC FIELDS=(C'RECCOUNT',9:1,3,C' TOTALAMOUNT ',25:30,14) 
/*                                                           


I am trying to sum on the first 3 bytes of the Input file & 14 bytes starting from 30th byte of Input file but i am getting S0C7. Can anyone please able to help me on this as i am trying to resolve this from quite some time now. I believe i am not using the correct format for second field. Please let me know your thoughts.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


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

PostPosted: Tue Jun 18, 2019 4:19 pm
Reply with quote

Have you looked up in the manual the various formats? You should have found, I believe, SFF.
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Tue Jun 18, 2019 4:49 pm
Reply with quote

Hi Nic,

Thanks for taking out the time to go through this. This is i have used
Code:
INREC OVERLAY=(30:30,14,SFF,TO=ZD,LENGTH=14)                       
 SORT FIELDS=(6,5,CH,A)                                             
 SUM FIELDS=(1,3,ZD,30,14,ZD)                                       
 OUTREC FIELDS=(C'RECCOUNT',9:1,3,                                   
       C' TOTALAMOUNT ',25:30,14,ZD,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-))

and this is working fine in Mainframe but when i am using this card in Linux, it is giving error on OVERLAY keyword. So wanted to ask if there is any way to achieve this without OVERYLAY and with SUM FIELDS ?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


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

PostPosted: Tue Jun 18, 2019 6:37 pm
Reply with quote

In what way did it "not work"? Show your DFSORT output.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Tue Jun 18, 2019 7:08 pm
Reply with quote

Poha Eater wrote:
Code:

----+----1----+----2----+----3----+----4---
********************************* Top of Da
001,"ALAOO","ACTUALS",119986,-0000000167.59
001,"ALAOO","ACTUALS",119986,-0000000186.04
001,"ALAOO","ACTUALS",119986,-0000001380.46
001,"ALAOO","ACTUALS",119986,-0000003265.91
001,"ALAOO","ACTUALS",119986, 0000000009.07
001,"ALAOO","ACTUALS",119986, 0000000023.56
001,"ALAOO","ACTUALS",119986, 0000000047.12
001,"ALAOO","ACTUALS",119986,-0000000004.98
001,"ALAOO","ACTUALS",119986,-0000000004.77


This is the SORT card which i have tried :
Code:
//SYSIN    DD *                                               
 SORT FIELDS=(6,5,CH,A)                                       
 SUM FIELDS=(1,3,ZD,30,14,ZD)                                 
 OUTREC FIELDS=(C'RECCOUNT',9:1,3,C' TOTALAMOUNT ',25:30,14) 
/*                                                           


The field "30,14" is not in format ZD.
Period.

1) RTFM
2) Specify the meaning of "not working" in plain English
3) Present your code samples, and results

Otherwise it's all just wasting of (our) time.
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Tue Jun 18, 2019 7:52 pm
Reply with quote

Hi,

Part of our application was earlier transferred on Linux and that is why some of the SORT keywords do not work in that environment. One of such SORT keyword is 'OVERLAY' which i have used in above given sort card.

So In other words, i have a constraint here where i have to achieve the requirement by using 'SUM FIELDS' & not using 'OVERLAY' keywords. If there is any solution available with these constraints, then please let me know.

I have already given my code above. Below is the sample output which i am expecting.
Code:
----+----1----+----2----+----3----+---
***************************** Top of D
RECCOUNT100 TOTALAMOUNT -0000032429.27
**************************** Bottom of


The sum which is starting from 9th & 25th byte is not the sum of above given sample Input records. It is just for reference that how output should be displayed.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Tue Jun 18, 2019 8:03 pm
Reply with quote

The field "30,14" is not in format ZD.
Your SUM= cannot work correctly.
Period.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Jun 18, 2019 8:49 pm
Reply with quote

if You post to the dfsort forum,
YOU SHOULD EXPECT SOLUTIONS MAKING USE OF ALL THE DFSORT CAPABILITIES

Will a good soul moderator move the topic somewhere else icon_cool.gif
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts Converting unpacked fields to pack us... SYNCSORT 4
No new posts Data for newly added fields not displ... IMS DB/DC 6
This topic is locked: you cannot edit posts or make replies. SUM FIELDS=NONE in reverse - Get dupl... DFSORT/ICETOOL 9
Search our Forums:

Back to Top