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

need logic

Former Member
0 Likes
596

Hi Friends,

I need the logic below .

VBELN VBELP LINENUMBER Pecentage

6789 10 1 80.00

6789 10 2 20.00

6789 10 3 80.00

6789 20 1 80.00

6789 20 2 10.00

6789 30 3 80.00

we need to calculate up to 100% or avilable Percentage(Not more tahn 100%) for that item, once it become 100% we need left the remaning rows of the item...

regards,

Ram

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
554

Hi,

By looping on one internal table, you do your below logic to find the percentage for the document and line item.

In the loop, for every record, keep adding this percentage to one variable, and if this variable exceeds 100% then do consider this line items.

Pseudo code might be like,

sort t_vbap by vbeln vbelp.

loop at t_vbap into w_vbap.

at new vbelp.

clear w_item.

endat.

if w_item is initial.

w_percentage = w_percentage + w_vbap-percentage.

if w_percentage > 100.

w_item = X.

endif.

at new vbeln.

clear w_percentage.

endat.

endif.

endloop.

4 REPLIES 4
Read only

Former Member
0 Likes
554

Hi ,

Try the following



data: v_percent type i,
         wa_itab like itab.
 
loop at itab.
v_ind = sy-tabix - 1.
 if v_percent < 100.
 read table itab into wa_itab index v_ind.
if itab-vbeln = wa_itab-vbeln and itab-vbelp = wa_itab-vbelp.
v_percent = itab-percentage.
itab-percentage = v_percent + itab-percentage.
modify itab.
endif.
endif.
endloop.

Regards,

Vik

Edited by: vikred on Jul 31, 2009 1:01 PM

Read only

Former Member
0 Likes
555

Hi,

By looping on one internal table, you do your below logic to find the percentage for the document and line item.

In the loop, for every record, keep adding this percentage to one variable, and if this variable exceeds 100% then do consider this line items.

Pseudo code might be like,

sort t_vbap by vbeln vbelp.

loop at t_vbap into w_vbap.

at new vbelp.

clear w_item.

endat.

if w_item is initial.

w_percentage = w_percentage + w_vbap-percentage.

if w_percentage > 100.

w_item = X.

endif.

at new vbeln.

clear w_percentage.

endat.

endif.

endloop.

Read only

Former Member
0 Likes
554

HI Ajai,

try this,

" itab_new type itab.


sort itab by vbeln.
loop at itab into wa.

at new VBELN.
clear temp_percentage.
endat.



temp_percentage = temp_percentage + wa-percentage.
if temp_percentage gt 100.
continue.
endif.
append wa to itab_new.
endloop.

itab_new will contained the desired data

Read only

digvijay_rai
Participant
0 Likes
554

hello ajay ,

just loop the data into a internal table .

data : percentage type < ur declation >

pass the percentage field to variable percentage .

then ,

loop at itab .

if percentage < 100 .

read table itab into wa_itab index idnx .

append wa_itab .

elseif percentage > 100 .

exit .

endloop .

thnx & Regards

Digviajy Rai

I need the logic below .

VBELN VBELP LINENUMBER Pecentage

6789 10 1 80.00

6789 10 2 20.00

6789 10 3 80.00

6789 20 1 80.00

6789 20 2 10.00

6789 30 3 80.00

we need to calculate up to 100% or avilable Percentage(Not more tahn 100%) for that item, once it become 100% we need left the remaning rows of the item...