Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

To compute sum of a field using syncsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
kalyan.v

New User


Joined: 04 Feb 2008
Posts: 65
Location: Hyd

PostPosted: Tue Dec 30, 2008 4:19 pm    Post subject: To compute sum of a field using syncsort
Reply with quote

Hi,

I have a requirement to find the total of one field and its corresponding record count.

Please see the below example.
Code:


Input:
          79(09)          170(2)
XXXXXXXXXX    +0.82XXXXXXXAB
XXXXXXXXXX   +20.65XXXXXXXAB
XXXXXXXXXX   +53.78XXXXXXXAB
XXXXXXXXXX   +13.34XXXXXXXAB
XXXXXXXXXX    +3.94XXXXXXXAB


Output should be like this:

1 3(8)     11(10)
AB       5+000009089   
  <------><-------->



I write below sort card using two output files to get the values.
Code:

//SYSIN DD *
   SORT FIELDS=(170,02,CH,A)
   OUTFIL FILES=01,REMOVECC,NODETAIL,
   INCLUDE=(83,02,CH,NE,C'+0'),
   SECTIONS=(170,02,
   TRAILER3=(170,02,
   COUNT,
   TOT=(79,09,SFF,EDIT=(STTTTTTTTT),SIGNS=(+,-))))
   OUTFIL FILES=02,REMOVECC,NODETAIL,
   INCLUDE=(83,02,CH,EQ,C'+0'),
   SECTIONS=(170,02,
   TRAILER3=(170,02,
   COUNT,
   TOT=(79,09,SFF,EDIT=(STTTTTTTTT),SIGNS=(+,-))))
/*


Output file 1:
AB 4+000009171
Output file 2:
AB 1+000000082

Using these two values i got the required sum using COBOL.
9171 - 0082 = 9089

Can i get the mentioned output in a single sortout file??

Thanks,
Kalyan
Back to top
View user's profile Send private message

krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Tue Dec 30, 2008 5:56 pm    Post subject:
Reply with quote

kalyan.v

Check the below sort card
Code:
//*******************************************************
//STEP001  EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
XXXXXXXXXX    +0.82XXXXXXXAB                             
XXXXXXXXXX   +20.65XXXXXXXAB                             
XXXXXXXXXX   +53.78XXXXXXXAB                             
XXXXXXXXXX   +13.34XXXXXXXAB                             
XXXXXXXXXX    +3.94XXXXXXXAB                             
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
 INREC IFTHEN=(WHEN=(15,2,CH,EQ,C'+0'),OVERLAY=(15:C'-'))
 SORT FIELDS=(27,02,CH,A)                                 
    OUTFIL REMOVECC,NODETAIL,                             
    SECTIONS=(27,02,                                     
    TRAILER3=(27,02,                                     
    COUNT,                                               
    TOT=(11,09,SFF,EDIT=(STTTTTTTTT),SIGNS=(+,-))))       

Change the positions as per your need

o/p looks like
Code:
AB       5+000009089
Back to top
View user's profile Send private message
kalyan.v

New User


Joined: 04 Feb 2008
Posts: 65
Location: Hyd

PostPosted: Wed Dec 31, 2008 10:21 am    Post subject:
Reply with quote

Hi krisprems,

Thanks for ur suggestion.It is working fine.

Thanks,
Kranthi V
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us