Application Development 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: 

modify <table> itab from <wa> issue

Former Member
0 Kudos

hello Experts,

I'm facing problem while using the modify statement.The problem is I want to modify the table from wa.

table having already 10 records with fields MANDT NAME1 NAME2 (lt_itab)

the wa ishaving the same fields.(ls_itab)

I wrote this statement, modify table lt_itab from ls_itab, the internal table has no effect when this is executed

It was returning sy-subrc as 4.

Please help me out.

thank you,

regards,

nagendra

8 REPLIES 8

Former Member
0 Kudos

Hi,

your can use

append <wa>  to <table>

it will insert at end of table.

Former Member
0 Kudos

Check the values for the workarea. All the primary keys of the Internal table should be same. Particularly check for MANDT. Normally it is best to specify the index or record number . Ex: modify

it_tab from wa_tab index lv_index.

Lv_index can be the sy-index of the loop.

archanapawar
Contributor
0 Kudos

You need to use index and transporting.


MODIFY i_itab INDEX sy-tabix TRANSPORTING name1.

Former Member
0 Kudos

But does the entry that you want to modify exists already in the internal table or not.

If you want to add a line you can use INSERT or APPEND ...

Former Member
0 Kudos

Hello,

Thanks for your replays I really appreciate. I solved the issue by myself by using the following statement.

modify itab from wa transporting f1 f2 f3 where key = 'value'.

thank you.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You need to use where condition and transporting as mentioned and remove table keyword in modify statement.

Sample:

  

types : begin of ty,
  name1(40) type c,
  name2(40) type c,
  end of ty.
  data : itab type standard table of ty,
        wa type ty.
  wa-name1 = 'ABC'.
  wa-name2 = 'XYZ'.
  append wa to itab.
  wa-name1 = 'DEF'.
  wa-name2 = 'UVT'.
  append wa to itab.
  clear wa.
  wa-name2 = 'ABC'.
  modify itab from wa transporting name2 where name2 <>' ABC'.
  loop at itab into wa.
    write : / wa-name1, wa-name2.
  endloop.

Former Member
0 Kudos

Hi,

Check key field values are exist. if they exist.

try below code.make sure all key field values are filled.

loop at it into wa.

" make required changes here

modify it from wa.

endloop.

Thanks,

Marimuthu.K

sireeshach
Explorer
0 Kudos

Hi Nagendra,

When you write a modify statement Modify itab from wa, first it will check whether there is any entry with the same key (based on the key of the internal table) and if the entry exists, it will be modified as per the work area else it will not be modified.

In your example, there might not be a record with the same key and so it is not modified.

To overcome this in the Modify statement add the table key based on which the table needs to be modified (using key addition) or using the Index.

Hope this helps.

Best Regards,

Sireesha Ch