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

Updating flag using itab

Former Member
0 Likes
1,437

Hi Guys

I need to update flag to X for all flag = I from my ztable. Ztable is a database table with many entries (10000's). I currently have code that implements this functionality but performance is very imp here so I need to fine tune the code, perhaps putting it in itab and modifying the entire table from it should work

This is what I have so far

  update ztable
  set flag = 'X'
  where flag = 'I'.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
953

Hi,

If you use the SET keyword, then you need to use all the key fields in the where condition, so better to dump all the data into a Internal table, then use below code

LOOP AT ITAB.
 update ztable
  set flag = 'X'
  where  Keyword1 = Itab-keyword1 and
            Keyword = Itab-keyword2 and
           flag = 'I'.

ENDLOOP.

Regards

Sudheer

3 REPLIES 3
Read only

Former Member
0 Likes
953

Hi,

Please try this.


loop at itab.
 move 'X' to itab-flag.
 modify itab.
endloop.

modify ztable from table itab. 

OR

loop at itab.
  update ztable
  set flag = 'X'
  where kunnr = itab-kunnr
    and vbeln = itab-vbeln.
endloop.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
953

loop at itab where flag = 'l'.

itab-flag = 'X'.

modify itab index sy-tabix.

endloop.

modify ztable from table itab.

Read only

Former Member
0 Likes
954

Hi,

If you use the SET keyword, then you need to use all the key fields in the where condition, so better to dump all the data into a Internal table, then use below code

LOOP AT ITAB.
 update ztable
  set flag = 'X'
  where  Keyword1 = Itab-keyword1 and
            Keyword = Itab-keyword2 and
           flag = 'I'.

ENDLOOP.

Regards

Sudheer