‎2007 Sep 10 7:53 PM
Hi experts,
i am looping at an item internal table i_vbrp. inside the loop i am getting 2 individual values, which i am appending to a final table i_finaltable. but in between i have to distribute the 2nd value to all line items based on 1st value in percentages and should be assigned to a 3rd value. and these split values should be appended to each line item. the code and example values look like this.
loop at i_vbrp.
read table i_konv...
i_finaltable-netwr = konv-kwert. value 1 1000 (A)
2000 (B) for each line item
3000 (C) when looping
read table i_bseg....
i_finaltable-wskto = i_bseg-wskto. value 2 ,300 fixed for a unique VBELN
endloop.
The value 300 should be distributed to each line item based on percentages.
value 1 value 2 value 3
1000 300 (1000/(1000+2000+3000)) * 300
2000 300 (2000/(1000+2000+3000)) * 300
3000 300 (3000/(1000+2000+3000)) * 300i should get the values like above in the final table, any suggestions will be awarded. Thanks in advance.
Thanks & Regards,
Poorna.
‎2007 Sep 10 8:21 PM
hi,
1. In the loop at i_vbrp. you sum up total of all
I assume you habe value 1 and value 2 as follow in the final table.
value 1 in some global variable. like
<i>loop at i_vbrp.
read table i_konv...
i_finaltable-netwr = konv-kwert. value 1 1000 (A)
2000 (B) for each line item
3000 (C) when looping
<b> wg_sum = wg_sum + i_finaltable-netwr</b>
read table i_bseg....
i_finaltable-wskto = i_bseg-wskto. value 2 ,300 fixed for a unique VBELN
endloop.</i>
2. Now in
<i>loop at i_finalitab.
i_finalitab-valu3 = ( i_finalitab-value1 / wg_sum ) * i_finalitab-value2.
modify i_finalitab.
endloop.</i>
this will give you dsired result. Let me know if you have any issue in this.
Enjoy SAP.
Pankaj Singh.
‎2007 Sep 10 8:21 PM
hi,
1. In the loop at i_vbrp. you sum up total of all
I assume you habe value 1 and value 2 as follow in the final table.
value 1 in some global variable. like
<i>loop at i_vbrp.
read table i_konv...
i_finaltable-netwr = konv-kwert. value 1 1000 (A)
2000 (B) for each line item
3000 (C) when looping
<b> wg_sum = wg_sum + i_finaltable-netwr</b>
read table i_bseg....
i_finaltable-wskto = i_bseg-wskto. value 2 ,300 fixed for a unique VBELN
endloop.</i>
2. Now in
<i>loop at i_finalitab.
i_finalitab-valu3 = ( i_finalitab-value1 / wg_sum ) * i_finalitab-value2.
modify i_finalitab.
endloop.</i>
this will give you dsired result. Let me know if you have any issue in this.
Enjoy SAP.
Pankaj Singh.