Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

regd : sum

Former Member
0 Likes
718

hi,

I have two fields in output.

profitcenter (prctr) wogbtr (Amount).

I want to display only subtotal of each profit center without displaying all the values.and subtotal text as corresponding profit center.please help me out in resolving this.

like

output is coming like this

prctr wogbtr

1010 200

1010 300

2020 300

2020 100

expected output.

1010 500.

2020 400.

total 900

6 REPLIES 6
Read only

Former Member
0 Likes
699

Hi

before sending the internal table to output sort it and use

ATNEW statement to add amounts of corresponding profit.

Read only

Former Member
0 Likes
699

Hi

First take final table into one more internal table and

for loop it like this (here I_analysis is final table and I_analytot is copied from i_analysis) ex:

LOOP AT i_analysis INTO wa_analytot.

AT NEW kunnr.

SUM.

READ TABLE i_analysis INTO wa_analysis WITH KEY kunnr = wa_analytot-kunnr

BINARY SEARCH.

APPEND wa_analytot TO i_analytot.

ENDAT.

ENDLOOP.

Regards

Rams

Edited by: ramesh on Feb 6, 2008 8:21 AM

Read only

Former Member
0 Likes
699

Hi,

sort itab by prctr wogbtr.

at end of wogbtr.
sum. 
write /wogbtr.
at last.
sum. 
write /wogbtr.

Cheers,

jose.

Edited by: jose on Feb 6, 2008 8:37 AM

Read only

Former Member
0 Likes
699

Hi

1st sort the ITAB

Use the Control breaks AT END OF in the LOOP

for eact at last, populate record into temp_ITAB

Then print this TEMP_ITAB

Reward if useful

nARENDRA

Read only

Former Member
0 Likes
699

Hi

To get subtotoal of any field , basis straties are

fields shud be sorted

1. sort profit center and amount

2. put a loop on internal table.

loop at itab.

endloop.

3. now use control statement to have sum of any field.

U can use AT NEW and SUM

or ON CHANGE OF.........ENDON.

logic is on change of profit center.

sum the amount.

hope concept is clear

. please reward points if helpful

Read only

Former Member
0 Likes
699

Hi Vinutha,

Use this one,

select prctr sum ( wogbtr ) into table itab from tablename

where ..........

group by prctr.

and then display the internal table itab.

  • Regards,*

Azhar.