IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

summing on character field


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mandyzzzz

New User


Joined: 04 Jul 2005
Posts: 23

PostPosted: Tue Nov 22, 2005 6:51 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Tue Nov 22, 2005 9:39 pm
Reply with quote

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
View user's profile Send private message
mandyzzzz

New User


Joined: 04 Jul 2005
Posts: 23

PostPosted: Tue Nov 22, 2005 11:10 pm
Reply with quote

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
View user's profile Send private message
mandyzzzz

New User


Joined: 04 Jul 2005
Posts: 23

PostPosted: Tue Nov 22, 2005 11:11 pm
Reply with quote

basically the problem is with the decimal points and minus sign in the character fields
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Nov 23, 2005 12:21 am
Reply with quote

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
View user's profile Send private message
mandyzzzz

New User


Joined: 04 Jul 2005
Posts: 23

PostPosted: Wed Nov 23, 2005 1:05 pm
Reply with quote

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
View user's profile Send private message
Phantom

New User


Joined: 04 Sep 2005
Posts: 25

PostPosted: Wed Nov 23, 2005 8:04 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Nov 23, 2005 9:39 pm
Reply with quote

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
View user's profile Send private message
mandyzzzz

New User


Joined: 04 Jul 2005
Posts: 23

PostPosted: Thu Nov 24, 2005 12:43 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Thu Nov 24, 2005 1:54 am
Reply with quote

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
View user's profile Send private message
mandyzzzz

New User


Joined: 04 Jul 2005
Posts: 23

PostPosted: Tue Nov 29, 2005 12:29 pm
Reply with quote

Is there any way I can use ICETOOL to do the same.

Thanks
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Tue Nov 29, 2005 9:54 pm
Reply with quote

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
View user's profile Send private message
mandyzzzz

New User


Joined: 04 Jul 2005
Posts: 23

PostPosted: Thu Dec 01, 2005 5:07 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Thu Dec 01, 2005 9:28 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top