i have doubt here you said you want to sum a particular field is it that
you want that sum on the key fields you have used in your case
its (7,4,CH,A) so
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
gram,
You need to explain clearly what you want before anyone can help you.
Your latest input and output is quite confusing. You have records with different keys (dddd, hhhh, kkkk) and 1111, 2222 and 3333 for the sum fields. Somehow you want to end up with 1111, 2222 and 6666. 6666 is the sum of the three fields, but why is it overlaying the last sum field? You need to explain the rules you want to use to get what you want.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
With SUM and SORT (or MERGE), you get only one record with each key containing the SUM, e.g.
engl nnn
math nnn
...
If you use INCLUDE, SUM will only be applied to the records you keep.
If you only have one key, you could use COPY with TOTAL in OUTFIL TRAILER1 to get the total rather than using SORT with SUM, although you can use SORT with SUM if you want to.
Your example has all kinds of problems (syntax errors, SUM isn't allowed with COPY, you can't sum a 3-byte BI field - it has to be 2, 4 or 8 bytes, but it's probably a 3-byte ZD field and will overflow, etc). I can't help you until I understand what you're trying to do.
So let me ask some questions:
1) What does your sum field really look like? Is it really a 3-byte BI value or is it a 3-byte ZD value or what? What does it look like in hex?
2) Do you just want the total for one key (e.g. 'ENGL') or for each key?
3) Do you want your output to have one record with the key and sum or do you want the output in some other form? If in some other form, what exactly do you want it to look like?
Actually, I'd say the best thing for you to do is go through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Gram,
If you want me to help you, you need to answer the first question I asked in my previous post:
1) What does your sum field really look like? Is it really a 3-byte BI value or is it a 3-byte ZD value or what? What does it look like in hex?
Also, what is the starting position of the sum field?
Quote:
right from the begining like this only tried with various examples but its not working...
It would help if you'd tell us in what way it isn't working. Is it getting an error message, or giving you the "wrong" output (show what you're getting) or something else?
I suspect your sum field is really not a 2-byte BI field, but I can't know that unless you show me what it looks like. If you don't know, you can use a DFSORT job like this to display the data in hex, and post the SORTOUT output: