how to write a aggregate sum function in dfsort



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

how to write a aggregate sum function in dfsort

Postby mainframemunic » Tue Dec 06, 2011 4:33 pm

//STEP1 EXEC PGM=SORT                                         
//SYSOUT DD SYSOUT=*                                         
//SORTIN DD DSN=xxxxx.PANDS.PS1,DISP=SHR                     
//SORTOUT DD DSN=xxxxxx.PANDS.PS2,DISP=(,CATLG,DELETE),...             
//SYSIN DD *                                                   
     SORT FIELDS=(9,3,CH,A)                                   
     SUM FIELDS=(1,2,ZD)                                       
/*                                                             
// 


above this program in output file i did't get the sum values....
some one help me i have input file which contains 10 fields with 10 records.
i want the the output file with summed up the five amount fileds and control on five fields. when ever any change in the first five fields i wnat the sum for alll the similar records.
when it is summing up is there any truncation will happen in the oputput file or not.
mainframemunic
 
Posts: 15
Joined: Thu Dec 01, 2011 1:14 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how to write a aggregate sum function in dfsort

Postby BillyBoyo » Tue Dec 06, 2011 4:55 pm

If you have five control fields, you need to put them all into the SORT card, in a logical order.

You can then SUM for each of the five fields.

If that is not what you want, you have to describe what you do want better.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: how to write a aggregate sum function in dfsort

Postby skolusu » Tue Dec 06, 2011 10:55 pm

mainframemunic,

use the following DFSORT control cards

//SYSIN DD *                                       
  OPTION EQUALS                                     
  SORT FIELDS=(P1,M1,F1,A,    $ CONTROL FIELD-1     
               P2,M2,F2,A,    $ CONTROL FIELD-2     
               P3,M3,F3,A,    $ CONTROL FIELD-3     
               P4,M4,F4,A,    $ CONTROL FIELD-4     
               P5,M5,F5,A)    $ CONTROL FIELD-5     
                                                   
   SUM FIELDS=(P1,M1,F1,      $ AMOUNT FIELD-1     
               P2,M2,F2,      $ AMOUNT FIELD-2     
               P3,M3,F3,      $ AMOUNT FIELD-3     
               P4,M4,F4,      $ AMOUNT FIELD-4     
               P5,M5,F5)      $ AMOUNT FIELD-5     
//*                                                 
 P = POSITION OF THE FIELD                         
 M = LENGTH OF THE FIELD                           
 F = FORMAT OF THE FIELD ( CH, ZD, PD .....)       


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: how to write a aggregate sum function in dfsort

Postby mainframemunic » Fri Dec 09, 2011 12:38 pm

skolusu
i have used above the code my program runs succesfully. but the results in not coming correctly. i did't get the sum of the values in my output file...
mainframemunic
 
Posts: 15
Joined: Thu Dec 01, 2011 1:14 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how to write a aggregate sum function in dfsort

Postby dick scherrer » Fri Dec 09, 2011 1:14 pm

Hello,

i have used above the code my program runs succesfully. but the results in not coming correctly
Then this would NOT be a successful run. . .

You need to post the jcl, control statements, and data that were used for the run and you need to post the informational messages (including messasge ids) generated by the run. Also show the output you generated as well as what you wanted.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: how to write a aggregate sum function in dfsort

Postby Frank Yaeger » Fri Dec 09, 2011 11:20 pm

i have used above the code my program runs succesfully. but the results in not coming correctly. i did't get the sum of the values in my output file...


Kolusu gave you a brief explanation of the general form of the DFSORT control statements (which you could have looked up in the DFSORT book). So you didn't use the "above code". You hopefully filled in your own position, length and format values. How do you expect anyone to know what you actually coded if you don't show it? You need to give us the appropriate information before we can help you. We can't read your mind or look over your shoulder.

If you want to learn how to code correct DFSORT statements yourself, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080
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: how to write a aggregate sum function in dfsort

Postby mainframemunic » Sat Dec 10, 2011 1:58 pm

Frank Yaeger
u first see the first post. i have posted the coding....
mainframemunic
 
Posts: 15
Joined: Thu Dec 01, 2011 1:14 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how to write a aggregate sum function in dfsort

Postby BillyBoyo » Sat Dec 10, 2011 2:35 pm

I'm thinking you are doing this deliberately or don't know enough to even recognise what you don't know.

The stuff you posted sorts on one field and sums on one field. If you want to sort on five and sum on five, you need to do it differently skolusu has shown you how.

If you can't understand even that, I don't think I'll be able to offer you anything further. It would be pointless.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: how to write a aggregate sum function in dfsort

Postby mainframemunic » Sat Dec 10, 2011 2:41 pm

in above my program i have added 1 and 2, but my output file i did't get any answer man
mainframemunic
 
Posts: 15
Joined: Thu Dec 01, 2011 1:14 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how to write a aggregate sum function in dfsort

Postby enrico-sorichetti » Sat Dec 10, 2011 8:53 pm

You did not post anything useful to the people willing help You
the sort behavior of the SUM <command> is well described in the manuals
before complaining verify that the SUM You are expecting agrees with the SUM rules of SORT

if , for example, Your input is
 =COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 000008 01      001                                                             
 000009 02      002                                                             
 000010 02      002                                                             
 000011 03      003                                                             
 000012 03      003                                                             
 000013 03      003                                                             


the result provided by SORT according to the SORT rules for the <Your SORT statements>
 000016 //SYSIN     DD *                                                       
 000017   SORT FIELDS=(9,3,CH,A)                                               
 000018   SUM FIELDS=(1,2,ZD)                                                   


is
01      001                                                                     
04      002                                                                     
09      003                                                                     


if You are expecting something else. do not whine it does not work, but rather explain better Your requirement

input ( a few records )
expected output ...
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post