Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Sort and Sum on input file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL
Author Message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Wed May 14, 2008 11:02 am    Post subject: Sort and Sum on input file
Reply with quote

I have a file

Eg.

Item Qty

123 5
123 6
345 3
345 2
345 1
789 5


I want the output to be like

Item Qty

123 11
345 6
789 5


ie , For all 123 item , the qty has to be summed up
For all 345 item , the qty has to be summed up
and so on

Can I do this using only the SORT utility .

Thanks a lot.
Back to top
View user's profile Send private message
References
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Wed May 14, 2008 11:08 am    Post subject:
Reply with quote

I found a similar post with gives a solution using DFSORT.

Since here we have SYNCSORT , can we do it using SYNCSORT.

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

Active User


Joined: 31 Aug 2006
Posts: 197
Location: At my Desk

PostPosted: Wed May 14, 2008 11:08 am    Post subject: Re: Sort and Sum on input file
Reply with quote

Aniyaa wrote:
I have a file

Eg.

Item Qty

123 5
123 6
345 3
345 2
345 1
789 5


I want the output to be like

Item Qty

123 11
345 6
789 5


ie , For all 123 item , the qty has to be summed up
For all 345 item , the qty has to be summed up
and so on

Can I do this using only the SORT utility .

Thanks a lot.


Use sumfields option of DFSORT.
Back to top
View user's profile Send private message
dick scherrer

Global Moderator


Joined: 23 Nov 2006
Posts: 8724
Location: 221 B Baker St

PostPosted: Wed May 14, 2008 11:08 am    Post subject:
Reply with quote

Hello,

Yes, you can sum values using Syncsort.

There are several examples in this JCL secton of the forum.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 197
Location: At my Desk

PostPosted: Wed May 14, 2008 11:11 am    Post subject:
Reply with quote

Aniyaa wrote:
I found a similar post with gives a solution using DFSORT.

Since here we have SYNCSORT , can we do it using SYNCSORT.

Thanks


sorry i ahve not noticed ur post.
I ahve no idea on Syncsort.Please search the forum u will get it.
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 133
Location: india

PostPosted: Wed May 14, 2008 11:32 am    Post subject:
Reply with quote

Hello Aniyaa,

You can use the below tested SYNCSORT JCL for your requrement:


Code:
//VZM1CKKN JOB (3GAHF3,R),                                         
//         'RAJAT TEST',CLASS=X,MSGCLASS=Y,NOTIFY=&SYSUID           
//STEP0100 EXEC PGM=SYNCSORT                                       
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
123 5                                                               
123 6                                                               
345 3                                                               
345 2                                                               
345 1                                                               
789 5                                                               
/*                                                                 
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  OPTION EQUALS                                                     
  SORT FIELDS=(1,3,CH,A)                                           
  OUTFIL REMOVECC,NODETAIL,                                         
    SECTIONS=(1,3,                     
       TRAILER3=(1,3,TOT=(4,2,ZD)))     
//*                                     



OUTPUT:

Code:
123             11   
345              6   
789              5   


I hope this helps

Regards,
Rajat
Back to top
View user's profile Send private message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Thu May 15, 2008 12:08 pm    Post subject:
Reply with quote

Thanks a lot for all the help and code
I will try them out and get back in case of any problems.

Thanks !!!!
Back to top
View user's profile Send private message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Thu May 15, 2008 12:19 pm    Post subject:
Reply with quote

I am just stuck here.
Suppose I have the input file as

123 5 1
123 6 2
345 3 4
345 2 3
345 1 7
789 5 5

I want the output as

123 11 3
345 6 14
789 5 5

i.e. there are 2 fields that need to be summed up .. in that case do i need to repeat the SECTIONS part.. I am not clear.
Can you pls help.
Back to top
View user's profile Send private message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Thu May 15, 2008 12:26 pm    Post subject:
Reply with quote

Yes tried it .. and got it.. just need to repeat the TOT field..

thanks..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL All times are GMT + 6 Hours
Page 1 of 1