View previous topic :: View next topic
|
Author |
Message |
mandyzzzz
New User
Joined: 04 Jul 2005 Posts: 23
|
|
|
|
Hi
Is it possible to sum up on character field?
i.e. sum fields=(x,y,ZD/PD/BI)
here if the field is character then what will be in place of ZD?
Thanks in advance!
Shamik. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
It depends on what the "character field" looks like. For example:
002
123
052
could be summed using ZD. You need to show me an example of what your character field looks like before I can answer your question. |
|
Back to top |
|
|
mandyzzzz
New User
Joined: 04 Jul 2005 Posts: 23
|
|
|
|
well it contains dollar amounts..
like:
024.33
-35.75
1234.50
-34.75
Any way we can sum this up?
Thanks
Shamik |
|
Back to top |
|
|
mandyzzzz
New User
Joined: 04 Jul 2005 Posts: 23
|
|
|
|
basically the problem is with the decimal points and minus sign in the character fields |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use DFSORT's SFF format to handle these types of values. You can use SFF directly in the TOTAL suboperand of TRAILERx to do the summing. For example:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
024.33
-35.75
1234.50
-34.75
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=(TOTAL=(1,7,SFF,EDIT=(STTTT.TT),SIGNS=(+,-)))
/*
|
SORTOUT will have:
+1188.33
You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) in order to use DFSORT's SFF format. Only DFSORT has this function, so if you don't have DFSORT, you won't be able to use it. If you do have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:
Use [URL] BBCode for External Links |
|
Back to top |
|
|
mandyzzzz
New User
Joined: 04 Jul 2005 Posts: 23
|
|
|
|
Can we do the summing up by sorting on another field?
Say in normal cases(ZD/PD)..we write
SORT FIELDS=(...................)
SUM FIELDS=(.................)
CAN WE DO THAT HERE TOO?
Thanks a lot for your kind help. |
|
Back to top |
|
|
Phantom
New User
Joined: 04 Sep 2005 Posts: 25
|
|
|
|
mandyzzzz,
Code: |
024.33
-35.75
1234.50
-34.75
|
Not directly. But you can use INREC to convert the floating decimal numbers to ZD/PD and then sort on a key and issue SUM FIELDS=(zd/pd).
Hope this answers your query,
Thanks,
Phantom |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
With DFSORT, you can use SORT, SECTIONS, TRAILER3 and TOTAL with SFF to do the equivalent directly, or you can convert the numbers with signs and decimal point to another format that you can use in SUM (such as ZD). If you want me to show you how to do one or the other, please show an example of your input records and what you want the output records to look like. Give the starting position, length and format of the relevent fields, and the RECFM and LRECL of the input file. The more specific example you give, the more specific solution I can give. |
|
Back to top |
|
|
mandyzzzz
New User
Joined: 04 Jul 2005 Posts: 23
|
|
|
|
Well my layout is of 245 bytes.Of which I want to sum on customer numbers which is pos 1 to pos7.The sum I want is of quantity (219 to 224) and dollars 225 to 236.
I would have loved to use
Sort fields=(1,7,ch,A)
SUM FIELDS(219,6,ZD,225,12,ZD)
But since both quantity and dollars are character fields, I cant do that.
So I would like to copy the entire rec to same file layout,just those two fields will not be character but ZD.
Then onwards I can proceed with the SORT and SUM thing.
Let me know how can I do that.
Thanks again.
You are of great help.
Shamik. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use DFSORT's SFF format to convert most types of data containing digits as well as signs, decimal points, separators, etc to ZD format. So you can probably do what you asked for with DFSORT like this:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
INREC OVERLAY=(219:219,6,SFF,TO=ZD,LENGTH=6,
225:225,12,SFF,TO=ZD,LENGTH=12)
SORT FIELDS=(1,7,CH,A)
SUM FIELDS(219,6,ZD,225,12,ZD)
/*
|
However, you will need the Dec, 2004 DFSORT PTF to use OVERLAY and SFF. And if you don't have DFSORT, you won't be able to use OVERLAY or SFF. |
|
Back to top |
|
|
mandyzzzz
New User
Joined: 04 Jul 2005 Posts: 23
|
|
|
|
Is there any way I can use ICETOOL to do the same.
Thanks |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Yes, you can use DFSORT's ICETOOL to do the same thing. You just have to wrap some additional ICETOOL JCL and control statements around it as follows:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=... output file
//TOOLIN DD *
SORT FROM(IN) TO(OUT) USING(CTL1)
/*
//CTL1CNTL DD *
INREC OVERLAY=(219:219,6,SFF,TO=ZD,LENGTH=6,
225:225,12,SFF,TO=ZD,LENGTH=12)
SORT FIELDS=(1,7,CH,A)
SUM FIELDS(219,6,ZD,225,12,ZD)
/*
|
|
|
Back to top |
|
|
mandyzzzz
New User
Joined: 04 Jul 2005 Posts: 23
|
|
|
|
Frank
Being the older version ,its not working in my shop.Any way we can work around this problem using the old DFSORT?
Shamik |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Shamik,
That depends. Is your input data really left-aligned like this:
Code: |
024.33
-35.75
1234.50
-34.75
|
or is it right-aligned like this (b for blank):
Code: |
b024.33
b-35.75
1234.50
b-34.75
|
|
|
Back to top |
|
|
|