Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us