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

To compute sum of a field using syncsort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
Search our Forums:

Back to Top