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
 

 

Sum accounts at every group break

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

New User


Joined: 06 Nov 2008
Posts: 46
Location: Manila, Philippines

PostPosted: Wed Sep 08, 2010 9:05 am    Post subject: Sum accounts at every group break
Reply with quote

Hi All,
I have a file that contains group and account totals:
Code:
AAB       ;          1,950.00;              0.00;          1,950.00;
05612112  ;              0.00;              0.00;              0.00;
05645002  ;              0.00;              0.00;              0.00;
11100008  ;              0.00;              0.00;              0.00;
11100035  ;              0.00;              0.00;              0.00;
11109112  ;          1,000.00;              0.00;          1,000.00;
11109113  ;            500.00;              0.00;            500.00;
11109147  ;            294.00;              0.00;            294.00;
11109150  ;            156.00;              0.00;            156.00;
AAC       ;          3,900.00;              0.00;          3,900.00;
05611159  ;          1,900.00;              0.00;          1,900.00;
05611887  ;          2,000.00;              0.00;          2,000.00;
AAD       ;              0.00;              0.00;              0.00;
05645002  ;              0.00;              0.00;              0.00;


I want to sum the accounts under the group and compare it with the group total. Groups are alphanumeric and accounts are all numeric. I am thinking of putting the group id at the end of the record so that I can sum the account totals using sum fields. I'm thinking my intermediary record to be something like:
Code:
GRP1  ; VALUE; VALUE; VALUE;
ACCT1 ; VALUE; VALUE; VALUE;GRP1X
ACCT2 ; VALUE; VALUE; VALUE;GRP1X
GRP2  ; VALUE; VALUE; VALUE;
ACCT3 ; VALUE; VALUE; VALUE;GRP2X
ACCT4 ; VALUE; VALUE; VALUE;GRP2X

where X is just an indicator to distinguish it from the group id.

But I am confused on how to use when=group in this case. I want my output to be something like:

Code:
AAB       ;          1,950.00;              0.00;          1,950.00;
AABX      ;          1,950.00;              0.00;          1,950.00;
AAC       ;          3,900.00;              0.00;          3,900.00;
AACX      ;          3,900.00;              0.00;          3,900.00;
AAD       ;              0.00;              0.00;              0.00;
AADX      ;              0.00;              0.00;              0.00;


Any ideas?

Input file is 163 BYTES, FB (there are 5 more amounts to be summed aside from shown)
Output file is also 163 bytes, FB.
Thanks
Back to top
View user's profile Send private message

darkstar13

New User


Joined: 06 Nov 2008
Posts: 46
Location: Manila, Philippines

PostPosted: Wed Sep 08, 2010 11:13 am    Post subject:
Reply with quote

Hi all,
I settled for now using 3 steps to accomplish my goal:

1. separate group from acct lines; use WHEN=GROUP to add group id
on acct lines
2. using acct file from #1, sum fields based on group id
3. Merge group file from #1 with acct totals from #2

Would anyone know how I can merge these two sort statements?
Thanks
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Wed Sep 08, 2010 12:02 pm    Post subject:
Reply with quote

how dou you identify a group start , anything that starts with A or it can be any non numeric character

instead of using 3 steps,
for the when=group, at the start of group, push the entire header,
then sun the records.
then you can split them up into 2 line using the / in outrec
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Wed Sep 08, 2010 4:02 pm    Post subject:
Reply with quote

Code:
//S020        EXEC PGM=ICETOOL                                         
//FILE1   DD  *                                                       
AAB       ;          1,950.00;              0.00;          1,950.00;   
05612112  ;              0.00;              0.00;              0.00;   
05645002  ;              0.00;              0.00;              0.00;   
11100008  ;              0.00;              0.00;              0.00;   
11100035  ;              0.00;              0.00;              0.00;   
11109112  ;          1,000.00;              0.00;          1,000.00;   
11109113  ;            500.00;              0.00;            500.00;   
11109147  ;            294.00;              0.00;            294.00;   
11109150  ;            156.00;              0.00;            156.00;   
AAC       ;          3,900.00;              0.00;          3,900.00;   
05611159  ;          1,900.00;              0.00;          1,900.00;   
05611887  ;          2,000.00;              0.00;          2,000.00;   
AAD       ;              0.00;              0.00;              0.00;   
05645002  ;              0.00;              0.00;              0.00;   
/*                                                                     
//TEMP     DD DSN=TEMP.TEST.DEL1,                                 
//             DISP=(NEW,CATLG),UNIT=DISK,                             
//             SPACE=(27998,(400,100),RLSE)                           
//FILEOUT  DD DSN=TEMP.TEST.DEL2,                                 
//             DISP=(NEW,CATLG),UNIT=DISK,                             
//             SPACE=(27998,(400,100),RLSE)                       
//TOOLIN   DD  *                                                   
   COPY FROM(FILE1) TO(TEMP) USING(CTL1)                           
   COPY FROM(TEMP) TO(FILEOUT) USING(CTL2)                         
//TOOLMSG  DD  SYSOUT=*                                           
//DFSMSG  DD  SYSOUT=*                                             
//CTL1CNTL DD  *                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,ZD,NE,NUM),PUSH=(164:1,163))
  OUTREC BUILD=(1,11,                                             
            12,18,UFF,TO=ZD,C';',                                 
            31,18,UFF,TO=ZD,C';',                                 
            50,18,UFF,TO=ZD,                                       
            68,259)                                               
  OUTFIL FNAMES=TEMP,INCLUDE(1,8,ZD,EQ,NUM)                       
//CTL2CNTL DD  *                                                   
  SORT FIELDS=(164,3,CH,A)                                         
  SUM FIELDS=(12,18,ZD,                                           
            31,18,ZD,                                             
            50,18,ZD)                                             
  OUTFIL OUTREC=(164,163,/,164,3,C'X',11:C';',                     
               12,18,ZD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-),C';',
               31,18,ZD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-),C';', 
               50,18,ZD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-),68,96)
Back to top
View user's profile Send private message
darkstar13

New User


Joined: 06 Nov 2008
Posts: 46
Location: Manila, Philippines

PostPosted: Wed Sep 15, 2010 8:28 am    Post subject:
Reply with quote

smijoss wrote:
how dou you identify a group start , anything that starts with A or it can be any non numeric character

instead of using 3 steps,
for the when=group, at the start of group, push the entire header,
then sun the records.
then you can split them up into 2 line using the / in outrec


group is any non-numeric character icon_biggrin.gif
thanks for the code.
i think my code will work too in one step if i use icetool, icon_biggrin.gif
but yours is much simpler, so thanks!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Sep 15, 2010 9:52 pm    Post subject: Reply to: Sum accounts at every group break
Reply with quote

darkstar13,

Here is an alternative way of getting the desired results in one pass.

You mentioned having 8 amount fields that needs to be summed, I just put ??? for the position. Replace them with the correct positions of the amount fields.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=Your input FB 163 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(167:8X'00000000000000000C')),       
  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,ZD,NE,NUM),PUSH=(164:1,3)),           
  IFTHEN=(WHEN=(1,3,ZD,EQ,NUM),                                       
  OVERLAY=(167:012,18,UFF,PD,LENGTH=9,     $ AMT -1                   
               031,18,UFF,PD,LENGTH=9,     $ AMT -2                   
               050,18,UFF,PD,LENGTH=9,     $ AMT -3                   
               ???,18,UFF,PD,LENGTH=9,     $ AMT -4                   
               ???,18,UFF,PD,LENGTH=9,     $ AMT -5                   
               ???,18,UFF,PD,LENGTH=9,     $ AMT -6                   
               ???,18,UFF,PD,LENGTH=9,     $ AMT -7                   
               ???,18,UFF,PD,LENGTH=9))    $ AMT -8                   
                                                                       
  SORT FIELDS=(164,3,CH,A),EQUALS                                     
                                                                       
  OUTFIL REMOVECC,NODETAIL,BUILD=(1,163),                             
  SECTIONS=(164,3,                                                     
  HEADER3=(1,163),                                                     
  TRAILER3=(164,3,C'X',11:C';',                                       
            TOT=(167,9,PD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-)),';',   
            TOT=(176,9,PD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-)),';',   
            TOT=(185,9,PD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-)),';',   
            TOT=(194,9,PD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-)),';',   
            TOT=(203,9,PD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-)),';',   
            TOT=(212,9,PD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-)),';',   
            TOT=(221,9,PD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-)),';',   
            TOT=(230,9,PD,EDIT=(SII,III,III,IIT.TT),SIGNS=(,-)),';')) 
//*
Back to top
View user's profile Send private message
darkstar13

New User


Joined: 06 Nov 2008
Posts: 46
Location: Manila, Philippines

PostPosted: Fri Sep 17, 2010 4:47 am    Post subject:
Reply with quote

thanks Kolusu! =) works great!
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 Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Select first 2 group data vice_versa DFSORT/ICETOOL 10 Mon Jun 13, 2016 2:21 pm
No new posts Hookup group of records in multiple p... V S Amarendra Reddy DFSORT/ICETOOL 3 Thu Feb 18, 2016 11:49 pm


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