Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Getting incorrect Output While summing the fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Getting incorrect Output While summing the fields
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    Post subject: Re: Getting incorrect Output While summing the fields
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    Post subject: Re: Getting incorrect Output While summing the fields
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 Moderator


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

PostPosted: Fri Nov 11, 2005 9:34 pm    Post subject:
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    Post subject: Re: Getting incorrect Output While summing the fields
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    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 Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Where is output from PARM ABEXIT (SNA... packerm CA Products 3 Thu Sep 28, 2017 4:06 pm
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts it is possible output a SET value fro... Martylin JCL & VSAM 5 Fri Sep 22, 2017 7:08 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us