‎2010 Jan 31 9:48 AM
Hello Experts,
Good Day,
I have an internal table in which i have to calculate the values of 1 column into another column based on another column. For example....
COL 1 COL 2 COL3 (sum of col 2 based on col 1)
120 1200
120 2000
120 1300 4500
121 1000
121 2000 3000
122 3000 3000
COL 1 COL 2 COL 3 (sum of col 2 based on col 1)
120 1200
2000
1300 4500
121 1000
2000 3000
122 3000 3000
Plz tell me how can i do this...also how to build the internal table like the 2nd table.
Thanks,
Tripod.
‎2010 Jan 31 10:01 AM
Hi, Tripod
Please Always USE more meaningful subject Line for your Query and do little Search before posting
You can achieve this by using Control Break Statement like AT NEW, AT END OF
Regards,
Faisal
‎2010 Jan 31 10:01 AM
HI Tripod ,
If I have understood your questions correctly, You need to calculate the subtotal of column 1 in column 3. Is it ?
If so , Proceed as follows :
Types : Begin of ty_tab,
col1 type vbeln,
col2 type i,
col3 type i,
end of ty_tab.
data : IT_TAB type standard table of ty_tab,
wa_tab type ty_tab.
Types : Begin of ty_tab1
col1 type vbeln,
col3 type i,
end of ty_tab1
data : IT_TAB1 type standard table of ty_tab1,
wa_tab1 type ty_tab1.
after this populate your internal table IT_TAB aas per your business requirement. Note that you will populate only column 1 and Column2.
Now,
loop at it_tab into wa_tab.
wa_tab1-col1 = wa_tab-col1.
wa_tab1-col3 = wa_tab-col2.
collect wa_tab1 into it_tab1.
endloop.
So now IT_TAB1 will contain the subtotal of column2 in IT_TAB based on column 1.
Hope this will help you.
Regards,
Nikhil
‎2010 Jan 31 11:24 AM
Hi Nikhil,
Actually i have to pass this internal table to my smartform. And AT NEW, AT END OF is not working here.
I tried your solution also...but not working.
Plz help me if you have more suggestions. In this internal table i have more fields also. but these columns are dependent on one another.
Thanks,
tripod.
‎2010 Jan 31 11:49 AM
>
>And AT NEW, AT END OF is not working here.
> tripod.
Hi,
For using AT NEW or AT END OF your Target Column must be left most side in internal table.
Regards,
Faisal