View previous topic :: View next topic
|
Author |
Message |
mikeleibo1
New User
Joined: 23 Jul 2007 Posts: 4 Location: GA
|
|
|
|
Sorry but I don't have a manual and trying to figure out what to do without it is pretty tough using the online manaual so thanks in advance for your help... Mike
We have variable records coming in with a sort key in columns 5-20. Starting in 21, left justified are numbers that I want to sum on equal keys:
I am not sure of the length of the field to be summed it might be max of 8
i.e.
1234567890123456789012345678901
lnth(-----------------key---------------)29 <== rec 1
lnth(-----------------key---------------)2900 <== rec 2
lnth(-----------------key---------------)290000 <== rec 3
output rec:
lnth(-----------------key---------------)292929 <== sum |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Mike and welcome to the forums,
If there is no definite length, how do you know when to "stop"? Is there some kind of delimiter? Is the only data after the key, the value to be summed (in all records)?
If you post the lrecl and recfm of the input file, show a more(?) representative sample of some input records, and post what you need for output, we should be able to offer suggestions.
There is a wealth of dfsort info here:
http://www.ibm.com/storage/dfsort/
Much may be downloaded. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Mike,
Assuming that lnth is actually the 4-byte RDW and that you want the sum values left-justified, you can use a DFSORT job like this:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB)
//SORTOUT DD DSN=... output file (VB)
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:21,8,UFF,TO=ZD,LENGTH=8))
SORT FIELDS=(5,16,CH,A)
OPTION ZDPRINT
SUM FIELDS=(21,8,ZD)
OUTREC OVERLAY=(21:21,8,ZD,TO=FS,LENGTH=8,
21:21,8,JFY=(SHIFT=LEFT))
/*
|
If that doesn't give you what you need, then please be more specific about what you do need. |
|
Back to top |
|
|
mikeleibo1
New User
Joined: 23 Jul 2007 Posts: 4 Location: GA
|
|
|
|
The column I'm summing is from total records reflecting the number of records in several files
So i'm trying to create a trailer...
It does have a max length - it may be up 9 long (up to several hundred million records |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
If the values to be summed can be up to 9 bytes long, then just change the control statements in the job I showed to:
Code: |
INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:21,9,UFF,TO=ZD,LENGTH=9))
SORT FIELDS=(5,16,CH,A)
OPTION ZDPRINT
SUM FIELDS=(21,9,ZD)
OUTREC OVERLAY=(21:21,9,ZD,TO=FS,LENGTH=9,
21:21,9,JFY=(SHIFT=LEFT))
|
|
|
Back to top |
|
|
mikeleibo1
New User
Joined: 23 Jul 2007 Posts: 4 Location: GA
|
|
|
|
the outrec had a format error - i deleted the last two lines and it works great!
Where are you? you deserve a beer |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
the outrec had a format error |
Did it flag JFY as the error? If so, you're missing the DFSORT April, 2006 PTF that added the JFY function. Ask your System Programmer to install z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006. For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
Use [URL] BBCode for External Links
The OUTREC statement's purpose is to left justify the sum. If you removed the OUTREC and got what you want, then you obviously don't need the sum left justified.
Quote: |
Where are you? you deserve a beer |
I'm in San Jose, CA. You can send me a virtual beer. |
|
Back to top |
|
|
mikeleibo1
New User
Joined: 23 Jul 2007 Posts: 4 Location: GA
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
hmmm ... tasty |
|
Back to top |
|
|
|