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

Internal Table - Modify

Former Member
0 Likes
333

Hi,

What I'd like to do is modify entries of an Internal table, from another another internal table, based on certain field logic.

For example, say my main internal table has two lines and 2 fields.

Fields Name Matnr

Line 1 Jim 1059

Line 2 Bush 2076

So then I loop through a different internal table and if the 2nd internal table has MATNR with value 2076, then change the name field or in a real cause, all of the corresponding fields (I use move-corresponding i_act to itab_data2.)

How do I do this?

Thanks,

Laura

2 REPLIES 2
Read only

Former Member
0 Likes
303

sort itab2 by matnr.

loop at itab1.

read table itab2 with key matnr = itab1-matnr.

l_index = sy-tabix.

if sy-subrc EQ 0.

loop at itab2 from index l_index.

if itab2-matnr EQ itab1-matnr.

<< populate the changed vaues here in itab2 header>>

modify itab2.

else.

exit.

endif

endloop.

endif.

endloop

    • reward if helpful**

Read only

Former Member
0 Likes
303

Hi,

Take help from example code as below :

sort itab by matnr.

sort itab1 by matnr.

loop at itab into wa_itab.

read table itab1 into wa_itab1 WITH KEY matnr = wa_itab-matnr BINARY SEARCH.

If sy-subrc eq 0.

move corresponding wa_itab1 to wa_itab.

modify table itab from wa_itab.

endif.

endloop.

Regards,

Sandeep Kaushik

Message was edited by:

Sandeep Kaushik