Skip to Content
avatar image
Former Member

modify <table> itab from <wa> issue

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

8 Answers

  • avatar image
    Former Member
    Jan 07, 2015 at 08:43 AM

    You need to use index and transporting.

    MODIFY i_itab INDEX sy-tabix TRANSPORTING name1.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 07, 2015 at 08:39 AM

    Hi,

    your can use

    append <wa>  to <table>

    it will insert at end of table.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 07, 2015 at 08:41 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 07, 2015 at 08:46 AM

    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 ...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 07, 2015 at 08:51 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 07, 2015 at 08:51 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 07, 2015 at 08:53 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 07, 2015 at 08:56 AM

    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

    Add comment
    10|10000 characters needed characters exceeded