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

loop

Former Member
0 Likes
766

hi to all

help in this issue

LOOP AT IT_FINAL.

IT_FINAL-CHANGE = IT_FINAL-CHANGE + IT_FINAL-DIFF.

IT_FINAL-PER = ( IT_FINAL-DIFF * 100 ) / IT_FINAL-CHANGE.

MODIFY IT_FINAL.

CLEAR IT_FINAL.

ENDLOOP.

here iam getting percentage per each record but i need percentage for whole change how can i achieive it

thanks in advance

kiran kumar.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
742

If you need the total percentage u need to calculate the same after the loop.

7 REPLIES 7
Read only

Former Member
0 Likes
743

If you need the total percentage u need to calculate the same after the loop.

Read only

Former Member
0 Likes
742

HI,

Sort the table on Change and use at end of change.


PSEUDO CODE
SORT IT_FINAL BY CHANGE.
LOOP AT IT_FINAL.
..
IT_FINAL-CHANGE = IT_FINAL-CHANGE + IT_FINAL-DIFF.
MODIFY IT_FINAL.


..

AT END OF CHANGE .
IT_FINAL-PER = ( IT_FINAL-DIFF * 100 ) / IT_FINAL-CHANGE.
MODIFY IT_FINAL.
CLEAR IT_FINAL.
END AT. 

Regards,

Raghav

Read only

Former Member
0 Likes
742
LOOP AT IT_FINAL.
*--in this loop we are calculating total values of all the records of V_CHANGE and V_DIFF
v_CHANGE = v_change + ( IT_FINAL-CHANGE + IT_FINAL-DIFF ).
v_diff = v_diff  + IT_FINAL-DIFF.
ENDLOOP.

*--here we are calculating percentage with the above summed values.
v_PER = ( v_DIFF * 100 ) / v_CHANGE.

define the variable V_CHANGE,V_DIFF AND v_per AS PER THEIR datatypes.

regards

srikanth

Message was edited by: Srikanth Kidambi

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
742
data: tmp_change type i.

clear tmp_change.
LOOP AT IT_FINAL.
tmp_change = tmp_change + IT_FINAL-DIFF.
ENDLOOP.

LOOP AT IT_FINAL.
IT_FINAL-PER = ( IT_FINAL-DIFF * 100 ) / tmp_change.
MODIFY IT_FINAL.
CLEAR IT_FINAL.
ENDLOOP.

Two loops out of the question?

Regards,

Rich Heilman

Read only

0 Likes
742

HI RICH,

clear tmp_change.

LOOP AT IT_FINAL.

tmp_change = tmp_change + IT_FINAL-DIFF.

ENDLOOP but here additon of change is not happening it is not statyinf in work area it is clearing.

thanks in advance

Read only

Former Member
0 Likes
742

You'll need an another LOOP to collect the whole data.

LOOP AT IT_FINAL. "+line

TOTAL = TOTAL + IT_FINAL-DIFF. "+line

ENDLOOP. "+line

and then your code...

LOOP AT IT_FINAL.

IT_FINAL-CHANGE = IT_FINAL-CHANGE + IT_FINAL-DIFF.

IT_FINAL-PER = ( IT_FINAL-DIFF * 100 ) / IT_FINAL-CHANGE.

IT_FINAL-total_PER = ( IT_FINAL-DIFF * 100 ) / TOTAL. "+line

MODIFY IT_FINAL.

CLEAR IT_FINAL.

ENDLOOP.

Best regards

Tamá

Read only

Former Member
0 Likes
742

Hi,

data lv_total type p,

lv_change type p.

LOOP AT IT_FINAL.

IT_FINAL-CHANGE = IT_FINAL-CHANGE + IT_FINAL-DIFF.

IT_FINAL-PER = ( IT_FINAL-DIFF * 100 ) / IT_FINAL-CHANGE.

lv_total = lv_total + it_final-per.

lv_change = lv_change + IT_FINAL-CHANGE.

MODIFY IT_FINAL.

CLEAR IT_FINAL.

ENDLOOP.

lv_total = (lv_total * 100 ) / lv_change.

Regards

Amole