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
 

 

confused about SUM function

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 41
Location: Taiwan

PostPosted: Fri Jan 23, 2015 8:32 am    Post subject: confused about SUM function
Reply with quote

The input content :

Code:
A  900100000006
A  900300000006
A  900600000013
A OTHER00000037


I want to SUM fields=(8,8),and expect the output:
Code:
A  900100000006
A  900300000006
A  900600000013
A OTHER00000037
       00000062


But, I can't get the summarized record.
The output file is the same as the input file.

The code I used:

Code:
//SYSIN DD *                   
   SORT FIELDS=(3,5,CH,A)     
   SUM  FIELDS=(8,8,BI)       
*  OUTREC FIELDS=(8,8)         
/*                             


Please help.
Back to top
View user's profile Send private message

chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Fri Jan 23, 2015 8:39 am    Post subject:
Reply with quote

Hi,

SUM function does not work as you are expecting.

SUM fuctions adds the SUM fields only for the duplicate keys and your output will have only one record.

Here you are sort keys are (3,5) means from your input records values are
' 9001', ' 9003',' 9006' and 'OTHER' which don't have any duplicatekeys.

Regards,
Chandan
Back to top
View user's profile Send private message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 41
Location: Taiwan

PostPosted: Fri Jan 23, 2015 8:56 am    Post subject:
Reply with quote

I changed the sort key to (1,1) as the following
Code:
//S1 EXEC PGM=SORT                                   
//SYSOUT DD SYSOUT=*                                 
//SORTIN DD *                                       
A  900100000006                                     
A  900300000006                                     
A  900600000013                                     
A OTHER00000037                                     
/*                                                   
//SORTOUT DD DSN= <output file name>                     
//SYSIN DD *                                         
   SORT FIELDS=(1,1,CH,A)                           
   SUM  FIELDS=(8,8,BI)                             
/*                                                   

The outcome is still the same!
Please help.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Jan 23, 2015 10:00 am    Post subject:
Reply with quote

You need TOT and TRAILER1 to get the desired output. Try the below SORT Card:

Code:
   OPTION COPY                                     
   OUTFIL REMOVECC,                               
          TRAILER1=(08:TOT=(8,8,ZD,TO=ZD,LENGTH=8))
Back to top
View user's profile Send private message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 41
Location: Taiwan

PostPosted: Fri Jan 23, 2015 10:22 am    Post subject:
Reply with quote

To Mistah, Thank you for the information.
I can get the total right now.
Code:
//SYSIN DD *                                           
*OPTION COPY                                           
   SORT FIELDS=(1,1,CH,A)                               
   OUTFIL REMOVECC,                                     
          TRAILER1=(08:TOT=(8,8,ZD,TO=ZD,LENGTH=8))     
/*                                                     


But, what is the reason that the SUM operator doesn't work in my code?
Can anyone care to explain?

Jacob
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Fri Jan 23, 2015 11:54 am    Post subject:
Reply with quote

Hi,

SUM function used for summing up the fields given for similar keys and create one record which will have summed value at given position

for example of you having 10 records of same key like yopu have 5 records with same key at (1,1,CH,A), then in output you will get only 1 record with value summed for 5 records.

Hope this is clear

Please refer below link chapter 4

http://publibz.boulder.ibm.com/epubs/pdf/ice2cg00.pdf

regards,
Chandan
Back to top
View user's profile Send private message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 41
Location: Taiwan

PostPosted: Fri Jan 23, 2015 12:23 pm    Post subject:
Reply with quote

Hello Chandan,
I can't find the very one record generated by SUM in the output file!!!

After changed the SORT FIELD to (1,1,CH,A), the SUM operator should add the value in field(8,8) of the input records.

Did I misunderstand your saying?

Jacob
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri Jan 23, 2015 1:06 pm    Post subject: Reply to: confused about SUM function
Reply with quote

Post the sysout from the step which didn't work (the SUM) and the step which did (the OUTFIL). Both should work, so let's find out why and why not.
Back to top
View user's profile Send private message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 41
Location: Taiwan

PostPosted: Fri Jan 23, 2015 1:16 pm    Post subject:
Reply with quote

SYSOUT which didn't work(the SUM)
Code:
********************************* TOP OF DATA **********************************
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1                         
ICE751I 0 C5-I12416 C6-K90026 C7-K94453 C8-K94453 E9-K60824 C9-BASE   E5-K80744
ICE143I 0 BLOCKSET     SORT  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 15:43 ON FRI JA
             SORT FIELDS=(1,1,CH,A)                                             
             SUM  FIELDS=(8,8,BI)                                               
ICE193I 0 ICEAM1 INVOCATION ENVIRONMENT IN EFFECT - ICEAM1 ENVIRONMENT SELECTED
ICE252I 1 PARMLIB OPTIONS WERE MERGED WITH INSTALLATION MODULE DEFAULTS         
ICE088I 1 DEGNSRXX.S1      .        , INPUT LRECL = 80, BLKSIZE = 80, TYPE = FB
ICE093I 0 MAIN STORAGE = (MAX,6291456,6278238)                                 
ICE156I 0 MAIN STORAGE ABOVE 16MB = (6217712,6217712)                           
ICE127I 0 OPTIONS: OVFLO=RC0 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC16,VLSCMP=N,SZERO=Y,
ICE128I 0 OPTIONS: SIZE=6291456,MAXLIM=1048576,MINLIM=450560,EQUALS=N,LIST=Y,ERE
ICE129I 0 OPTIONS: VIO=N,RESDNT=ALL ,SMF=SHORT,WRKSEC=Y,OUTSEC=Y,VERIFY=N,CHALT=
ICE130I 0 OPTIONS: RESALL=4096,RESINV=0,SVC=109 ,CHECK=Y,WRKREL=Y,OUTREL=Y,CKPT=
ICE131I 0 OPTIONS: TMAXLIM=6291456,ARESALL=0,ARESINV=0,OVERRGN=65536,CINV=Y,CFW=
ICE132I 0 OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE    ,EXITC
ICE133I 0 OPTIONS: HIPRMAX=OPTIMAL,DSPSIZE=MAX ,ODMAXBF=0,SOLRF=Y,VLLONG=N,VSAMI
ICE235I 0 OPTIONS: NULLOUT=RC0                                                 
ICE236I 0 OPTIONS: DYNAPCT=10 ,MOWRK=N                                         
ICE084I 0 EXCP ACCESS METHOD USED FOR SORTOUT                                   
ICE084I 0 BSAM ACCESS METHOD USED FOR SORTIN                                   
ICE750I 0 DC 500000 TC 0 CS DSVUU KSZ 1 VSZ 1                                   
ICE752I 0 FSZ=6250 RC  IGN=0 E  AVG=80 0  WSP=650 C  DYN=0 0                   
ICE751I 1 DE-K83743 D5-K91600 D9-K61787 E8-I12416                               
ICE090I 0 OUTPUT LRECL = 80, BLKSIZE = 27920, TYPE = FB   (SDB)                 
ICE152I 0 OVERFLOW DURING SUMMATION - RC=0                                     
ICE080I 0 IN MAIN STORAGE SORT                                                 
ICE055I 0 INSERT 0, DELETE 0                                                   
ICE054I 0 RECORDS - IN: 4, OUT: 4                                               
ICE134I 0 NUMBER OF BYTES SORTED: 320                                           
ICE253I 0 RECORDS SORTED - PROCESSED: 4, EXPECTED: 6250                         
ICE199I 0 MEMORY OBJECT USED AS MAIN STORAGE = 0M BYTES                         
ICE299I 0 MEMORY OBJECT USED AS WORK STORAGE = 0M BYTES                         
ICE180I 0 HIPERSPACE STORAGE USED = 0K BYTES                                   
ICE188I 0 DATA SPACE STORAGE USED = 0K BYTES                                   
ICE052I 0 END OF DFSORT                                                         
******************************** BOTTOM OF DATA ********************************
Back to top
View user's profile Send private message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 41
Location: Taiwan

PostPosted: Fri Jan 23, 2015 1:18 pm    Post subject:
Reply with quote

SYSOUT which worked(the OUTFIL)
Code:
********************************* TOP OF DATA **********************************
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1                         
ICE751I 0 C5-I12416 C6-K90026 C7-K94453 C8-K94453 E4-K58148 C9-BASE   E5-K80744
ICE143I 0 BLOCKSET     SORT  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 15:46 ON FRI JA
             SORT FIELDS=(1,1,CH,A)                                             
             OUTFIL REMOVECC,                                                   
                    TRAILER1=(08:TOT=(8,8,ZD,TO=ZD,LENGTH=8))                   
ICE193I 0 ICEAM1 INVOCATION ENVIRONMENT IN EFFECT - ICEAM1 ENVIRONMENT SELECTED
ICE252I 1 PARMLIB OPTIONS WERE MERGED WITH INSTALLATION MODULE DEFAULTS         
ICE088I 1 DEGNSRXX.S1      .        , INPUT LRECL = 80, BLKSIZE = 80, TYPE = FB
ICE093I 0 MAIN STORAGE = (MAX,6291456,6266880)                                 
ICE156I 0 MAIN STORAGE ABOVE 16MB = (6209520,6209520)                           
ICE127I 0 OPTIONS: OVFLO=RC0 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC16,VLSCMP=N,SZERO=Y,
ICE128I 0 OPTIONS: SIZE=6291456,MAXLIM=1048576,MINLIM=450560,EQUALS=N,LIST=Y,ERE
ICE129I 0 OPTIONS: VIO=N,RESDNT=ALL ,SMF=SHORT,WRKSEC=Y,OUTSEC=Y,VERIFY=N,CHALT=
ICE130I 0 OPTIONS: RESALL=4096,RESINV=0,SVC=109 ,CHECK=Y,WRKREL=Y,OUTREL=Y,CKPT=
ICE131I 0 OPTIONS: TMAXLIM=6291456,ARESALL=0,ARESINV=0,OVERRGN=65536,CINV=Y,CFW=
ICE132I 0 OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE    ,EXITC
ICE133I 0 OPTIONS: HIPRMAX=OPTIMAL,DSPSIZE=MAX ,ODMAXBF=2097152,SOLRF=Y,VLLONG=N
ICE235I 0 OPTIONS: NULLOUT=RC0                                                 
ICE236I 0 OPTIONS: DYNAPCT=10 ,MOWRK=N                                         
ICE084I 0 BSAM ACCESS METHOD USED FOR SORTIN                                   
ICE750I 0 DC 500000 TC 0 CS DSVVV KSZ 1 VSZ 1                                   
ICE752I 0 FSZ=6250 RC  IGN=0 E  AVG=80 0  WSP=650 C  DYN=13 56648               
ICE231I 0 STORAGE USED FOR OUTFIL : BELOW 16M = 20480, ABOVE 16M = 2121728     
ICE210I 0 SORTOUT  : EXCP USED, LRECL = 80, BLKSIZE = 27920, TYPE = FB   (SDB) 
ICE751I 1 DE-K83743 D5-K91600 D9-K61787 CB-K64632 E8-I12416                     
ICE080I 0 IN MAIN STORAGE SORT                                                 
ICE055I 0 INSERT 0, DELETE 0                                                   
ICE054I 0 RECORDS - IN: 4, OUT: 4                                               
ICE227I 0 SORTOUT  : DELETED = 0, REPORT = 1, DATA = 4                         
ICE228I 0 SORTOUT  : TOTAL IN = 4, TOTAL OUT = 5                               
ICE134I 0 NUMBER OF BYTES SORTED: 320                                           
ICE253I 0 RECORDS SORTED - PROCESSED: 4, EXPECTED: 6250                         
ICE165I 0 TOTAL WORK DATA SET TRACKS ALLOCATED: 15 , TRACKS USED: 0             
ICE199I 0 MEMORY OBJECT USED AS MAIN STORAGE = 0M BYTES                         
ICE299I 0 MEMORY OBJECT USED AS WORK STORAGE = 0M BYTES                         
ICE180I 0 HIPERSPACE STORAGE USED = 0K BYTES                                   
ICE188I 0 DATA SPACE STORAGE USED = 0K BYTES                                   
ICE052I 0 END OF DFSORT                                                         
******************************** BOTTOM OF DATA ********************************
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Fri Jan 23, 2015 1:54 pm    Post subject:
Reply with quote

Hi,

you are using ZD in outfil step so its working fine

If you change card to
Code:
SUM FIELDS=(8,8,ZD)
you will get the desired result of 1 record in 1st case as well

Regards,
Chandan
Back to top
View user's profile Send private message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 41
Location: Taiwan

PostPosted: Fri Jan 23, 2015 2:29 pm    Post subject:
Reply with quote

Yes, indeed.

Thank you very much.
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
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm


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