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

Getting incorrect Output While summing the fields


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

New User


Joined: 28 Jul 2005
Posts: 58

PostPosted: Fri Nov 11, 2005 11:38 am
Reply with quote

Hi Friends,

I am getting incorrect Output While summing the fields. Can u please correct me what mistake I have made.

I want the Output as :

411


Following is the code i am using.

//JOB1 JOB (U,1019),'AAA',CLASS=0,MSGCLASS=X,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//S1 EXEC PGM=ICEMAN
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=A.B.PS1,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,3,ZD)
/*


INPUT FILE:
==========

ZZZ 111
BBB 100
CCC 200

OUTPUT:
========


********************************
BBB 100
CCC 200
ZZZ 111
********************************
Back to top
View user's profile Send private message
raajan_p

New User


Joined: 19 Sep 2005
Posts: 17

PostPosted: Fri Nov 11, 2005 12:53 pm
Reply with quote

Hi,

the output is correct.

it will be displayed as

BBB 100
CCC 200
ZZZ 111

according to your input and SYSIN statement. If you want the output to be 411 then your input should have been

BBB 100
BBB 200
BBB 111

if the input file is like

ZZZ 111
CCC 200
CCC 100
Then your output would be

CCC 300
ZZZ 111.

Hope you get wat i am trying to say. Please correct me if i am wrong.
Back to top
View user's profile Send private message
suganthyprabha

New User


Joined: 28 Jul 2005
Posts: 58

PostPosted: Fri Nov 11, 2005 2:03 pm
Reply with quote

Hi rajan,

Thanks for ur Reply. I got that.
I am having one more doubt.

Suppose my input file is as foll.

110
100
050
300

I want to sort and Sum this fields.

So i have tried like

//SYSIN DD *
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(1,3,ZD)

S000 U0016 stating that

ILLEGAL OVERLAPPING OF SUM FIELDS .

So can u please let me know regarding this.

Thanks and Regards,
Suganthy.
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: Fri Nov 11, 2005 9:34 pm
Reply with quote

SUM works with equal SORT keys. If you don't have equal SORT keys, the fields aren't summed. If you do have equal SORT keys, then you get a sum for each sort key.

In your first post, you did not have any equal SORT keys, so none of the records were summed. If you want a total of the field for all of the records, you can use these DFSORT statements:

Code:

   OPTION COPY
   OUTFIL REMOVECC,NODETAIL,
      OUTREC=(TOT=(1,3,ZD,TO=ZD,LENGTH=3))


In your second post, you used the same field for SORT and SUM - that's not allowed, and if it were, nothing would be summed because none of the keys (the sum fields) would be equal. If you used:

Code:

   SORT FIELDS=(4,1,CH,A)
   OPTION ZDPRINT
   SUM FIELDS=(1,3,ZD)


that would give you a total. The sort key (1 blank) would be equal for every record, so the field would be summed. Note that I added ZDPRINT to ensure that the records are readable (F sign).
Back to top
View user's profile Send private message
suganthyprabha

New User


Joined: 28 Jul 2005
Posts: 58

PostPosted: Wed Nov 16, 2005 11:07 am
Reply with quote

Hi Frank,

Thank u so much. Now only i have the clear idea about the SUM.

Thanks and Regards,
Suganthyprabha.
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 TRIM everything from input, output co... DFSORT/ICETOOL 0
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts Build a record in output file and rep... DFSORT/ICETOOL 11
No new posts XDC SDSF output to temp dataset CLIST & REXX 4
Search our Forums:

Back to Top