Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
mandyzzzz

New User

Joined: 04 Jul 2005
Posts: 23

 Posted: Tue Nov 22, 2005 6:51 pm    Post subject: summing on character field 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.

Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

 Posted: Tue Nov 22, 2005 9:39 pm    Post subject: 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.
mandyzzzz

New User

Joined: 04 Jul 2005
Posts: 23

 Posted: Tue Nov 22, 2005 11:10 pm    Post subject: well it contains dollar amounts.. like: 024.33 -35.75 1234.50 -34.75 Any way we can sum this up? Thanks Shamik
mandyzzzz

New User

Joined: 04 Jul 2005
Posts: 23

 Posted: Tue Nov 22, 2005 11:11 pm    Post subject: basically the problem is with the decimal points and minus sign in the character fields
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Wed Nov 23, 2005 12:21 am    Post subject:

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:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/
mandyzzzz

New User

Joined: 04 Jul 2005
Posts: 23

 Posted: Wed Nov 23, 2005 1:05 pm    Post subject: 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.
Phantom

New User

Joined: 04 Sep 2005
Posts: 25

Posted: Wed Nov 23, 2005 8:04 pm    Post subject:

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).

Thanks,
Phantom
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

 Posted: Wed Nov 23, 2005 9:39 pm    Post subject: 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.
mandyzzzz

New User

Joined: 04 Jul 2005
Posts: 23

 Posted: Thu Nov 24, 2005 12:43 am    Post subject: 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.
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Thu Nov 24, 2005 1:54 am    Post subject:

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.
mandyzzzz

New User

Joined: 04 Jul 2005
Posts: 23

 Posted: Tue Nov 29, 2005 12:29 pm    Post subject: Is there any way I can use ICETOOL to do the same. Thanks
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Tue Nov 29, 2005 9:54 pm    Post subject:

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) /*
mandyzzzz

New User

Joined: 04 Jul 2005
Posts: 23

 Posted: Thu Dec 01, 2005 5:07 pm    Post subject: Frank Being the older version ,its not working in my shop.Any way we can work around this problem using the old DFSORT? Shamik
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Thu Dec 01, 2005 9:28 pm    Post subject:

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
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Splitting one row into multiple Rows ... Rajan Moorthy DFSORT/ICETOOL 9 Mon May 14, 2018 10:58 pm How to include a particular field val... sakrat DFSORT/ICETOOL 8 Fri Apr 06, 2018 8:27 pm Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am Invalid XML character while producing... nikhil.bhole IBM Tools 4 Tue Mar 20, 2018 1:24 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us