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
 
Sort and Sum on input file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
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

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: 215
Location: India

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

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

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: 215
Location: India

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: 195
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
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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am

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