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

Sort and Sum on input file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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: 218
Location: India

PostPosted: Wed May 14, 2008 11:08 am
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

Moderator Emeritus


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

PostPosted: Wed May 14, 2008 11:08 am
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: 218
Location: India

PostPosted: Wed May 14, 2008 11:11 am
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: 199
Location: india

PostPosted: Wed May 14, 2008 11:32 am
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top