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

UPDATE field in internal table?

Former Member
0 Likes
33,214

Hi,

I have an internal table with XXXXXXXX records. I have to UPDATE 1 field with the same value.

Is there a faster way?


    LOOP AT lt_order_adm_h INTO wa_order_adm_h.
      wa_order_adm_h-process_type = 'Z002'.
      MODIFY lt_order_adm_h FROM wa_order_adm_h TRANSPORTING process_type.
    ENDLOOP.

tnx, Adibo.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
10,262

HI Adibo,

Try below

data: lv_tabix type i.  "take this index aswell for better perfromance.
    LOOP AT lt_order_adm_h INTO wa_order_adm_h .
      lv_index = sy-tabix.
      wa_order_adm_h-process_type = 'Z002'.
      MODIFY lt_order_adm_h FROM wa_order_adm_h index lv_index TRANSPORTING process_type.
    ENDLOOP.

or you can do one more thing.

if you want to modify only process_type field ( which is initail ) for whole table.

just do below

wa_order_adm_h-process_type = 'Z002'.
modify lt_order_adm_h from wa_order_adm_h tranporting process_type where process_type is '  ' .

any ways modify is the faster way.

Regards

Edited by: Prasanth on Mar 4, 2009 5:35 PM

Hi,

I have an internal table with XXXXXXXX records. I have to UPDATE 1 field with the same value.

Is there a faster way?


    LOOP AT lt_order_adm_h INTO wa_order_adm_h.
      wa_order_adm_h-process_type = 'Z002'.
      MODIFY lt_order_adm_h FROM wa_order_adm_h TRANSPORTING process_type.
    ENDLOOP.

tnx, Adibo.

9 REPLIES 9
Read only

Former Member
0 Likes
10,262

Hi,

maybe this is faster.

process_type = 'Z002'.

MODIFY lt_order_adm_h TRANSPORTING process_type WHERE process_type ne 'Z002'.

Read only

Former Member
0 Likes
10,263

HI Adibo,

Try below

data: lv_tabix type i.  "take this index aswell for better perfromance.
    LOOP AT lt_order_adm_h INTO wa_order_adm_h .
      lv_index = sy-tabix.
      wa_order_adm_h-process_type = 'Z002'.
      MODIFY lt_order_adm_h FROM wa_order_adm_h index lv_index TRANSPORTING process_type.
    ENDLOOP.

or you can do one more thing.

if you want to modify only process_type field ( which is initail ) for whole table.

just do below

wa_order_adm_h-process_type = 'Z002'.
modify lt_order_adm_h from wa_order_adm_h tranporting process_type where process_type is '  ' .

any ways modify is the faster way.

Regards

Edited by: Prasanth on Mar 4, 2009 5:35 PM

Read only

Former Member
0 Likes
10,262

Hi Adibo,

Try this...

LOOP AT lt_order_adm_h INTO wa_order_adm_h where process_type = 'Z002'
       
  if sy-subrc = 0. 
       MODIFY lt_order_adm_h FROM wa_order_adm_h TRANSPORTING process_type.
  endif. 
   ENDLOOP.

Hope it is helpful...

Regards,

Kittu

Read only

Former Member
0 Likes
10,262

Hi

Use field symbols

Loop at itab assigning <ITAB>.

<ITAB>-name1 = 'KIRAN'.

endloop.

no need of update or modify statement.

Kiran

Read only

Former Member
0 Likes
10,262

I have to update ALL records but only one field, process_type

Read only

Former Member
0 Likes
10,262

You can evaluate from Se30?.Tips and tricks>Internal tables>Modifying single lines. It is bit explanatory as well.

Read only

Former Member
0 Likes
10,262

Hi

Just Put where condition, it would work.

Regard

Shashi

Read only

Former Member
0 Likes
10,262

This is OK.


    LOOP AT lt_order_adm_h INTO wa_order_adm_h.
      wa_order_adm_h-process_type = 'Z002'.
      MODIFY lt_order_adm_h FROM wa_order_adm_h INDEX sy-tabix TRANSPORTING process_type.
    ENDLOOP.

1 XXXX 2323444

2 XXXX 4749239

3 XXXX 3840505

4 XXXX 4049494

5 XXXX 4048372

So XXXX should be updated to Z002, that's is.

Read only

Former Member
0 Likes
10,262

Hi,

More faster way to do this would be to Use "LOOP AT itab ASSIGNING ." instead of using a work area , you avoid data transport into the work area. The field symbol is a pointer into(!) the table so that you can modify the table line directly; you don't need MODIFY thus avoiding another data transport.

FIELD-SYMBOLS: <fs> TYPE <type of lt_order_adm_h>.

 LOOP AT lt_order_adm_h ASSIGNING <fs>.
      <fs>-process_type = 'Z002'.
 ENDLOOP.

Regards,

Neha