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:
Joined: 06 Nov 2008 Posts: 46 Location: Manila, Philippines
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
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
Joined: 06 Nov 2008 Posts: 46 Location: Manila, Philippines
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
thanks for the code.
i think my code will work too in one step if i use icetool,
but yours is much simpler, so thanks!
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
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