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

Data Manipulation in internal table

former_member810660
Participant
0 Likes
343

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)) * 300

i should get the values like above in the final table, any suggestions will be awarded. Thanks in advance.

Thanks & Regards,

Poorna.

1 ACCEPTED SOLUTION
Read only

messier31
Active Contributor
0 Likes
318

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.

1 REPLY 1
Read only

messier31
Active Contributor
0 Likes
319

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.