ADD THE VALUES USING SUM



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

ADD THE VALUES USING SUM

Postby MAINFRAME GURU » Wed Jul 15, 2009 11:25 pm

Hi guys,

I am trying to sum the prices of a particular book using "SUM". However, I am not getting the SUM... I am getting all the records.

Here are the details

Input file is :

1001 MATHS 200
1002 ENG   250
1002 ENG   235
1002 ENG   215


Expected Output:

1002 ENG   700


Current output :

1002 ENG  250
1002 ENG  235
1002 ENG  215


Code is below :

//STEP2    EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD DSN=XYZ.TEST1.ISORT,DISP=SHR               
//SORTOUT  DD DSN=XYZ.TEST1.OSORT,DISP=(NEW,CATLG,DELETE),
//           SPACE=(CYL,(1,1),RLSE),                         
//           DCB=(BLKSIZE=8000,LRECL=80,RECFM=FB)             
//SYSIN    DD *                                               
    SORT FIELDS=(1,4,CH,A)                                   
    INCLUDE COND=(6,5,CH,EQ,C'ENG  ')                         
    SUM FIELDS=(12,4,BI)                                     
/*                           


I am using Z/OS DFSORT V1R5.

Can anyone please help me?
MAINFRAME GURU
 
Posts: 18
Joined: Fri Jul 10, 2009 8:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: ADD THE VALUES USING SUM

Postby MAINFRAME GURU » Thu Jul 16, 2009 12:50 am

I have also seen this message

ICE152I 0 OVERFLOW DURING SUMMATION - RC=0

and then I changed it from BI to ZD with the below code

SUM FIELDS=(12,2,ZD)


But I got wrong sum

which is 690 instead of 700.

PS :- I changed from (12,4,BI) to (12,2,ZD) {not (12,4,ZD) as its giving S0C7 error}.

Can you please help me?
MAINFRAME GURU
 
Posts: 18
Joined: Fri Jul 10, 2009 8:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: ADD THE VALUES USING SUM

Postby Frank Yaeger » Thu Jul 16, 2009 1:35 am

As far as I can tell, your amount field is in positions 12-14, so you should be using 12,3,ZD, not 12,4,BI or 12,3,ZD or 12,4,ZD. When I used this with DFSORT:

    SORT FIELDS=(1,4,CH,A)               
    INCLUDE COND=(6,5,CH,EQ,C'ENG')       
    SUM FIELDS=(12,3,ZD)                 


The output was:

1002 ENG   700     


You need to be careful to get the starting position and length right.

Alternatively, you could use 11,4,ZD which would give you the following and prevent overflow if you total is greater than 999:

1002 ENG  0700


If you want something else, state more clearly exactly what you want.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: ADD THE VALUES USING SUM

Postby MAINFRAME GURU » Thu Jul 16, 2009 2:12 am

Thanks Frank for your help!!!

Its working fine now...

Regards,
Guru
MAINFRAME GURU
 
Posts: 18
Joined: Fri Jul 10, 2009 8:41 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post