View previous topic :: View next topic
|
Author |
Message |
Aniyaa
New User
Joined: 07 Dec 2007 Posts: 26 Location: Bangalore
|
|
|
|
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 |
|
|
Aniyaa
New User
Joined: 07 Dec 2007 Posts: 26 Location: Bangalore
|
|
|
|
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 |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yes, you can sum values using Syncsort.
There are several examples in this JCL secton of the forum. |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
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 |
|
|
rajatbagga
Active User
Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
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:
I hope this helps
Regards,
Rajat |
|
Back to top |
|
|
Aniyaa
New User
Joined: 07 Dec 2007 Posts: 26 Location: Bangalore
|
|
|
|
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 |
|
|
Aniyaa
New User
Joined: 07 Dec 2007 Posts: 26 Location: Bangalore
|
|
|
|
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 |
|
|
Aniyaa
New User
Joined: 07 Dec 2007 Posts: 26 Location: Bangalore
|
|
|
|
Yes tried it .. and got it.. just need to repeat the TOT field..
thanks.. |
|
Back to top |
|
|
|