Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

summing on character field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: summing on character field
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 Moderator


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

PostPosted: Tue Nov 22, 2005 9:39 pm    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Nov 23, 2005 12:21 am    Post subject:
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:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Nov 23, 2005 9:39 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Thu Nov 24, 2005 1:54 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Tue Nov 29, 2005 9:54 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Thu Dec 01, 2005 9:28 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us