Skip to Content
avatar image
Former Member

TABLE ILLEGAL STATEMENT error with MODIFY command

Hi gurus,

i want you to inform me about table illegal statement error. The error occurs when i use modify as below.

loop at itab.

select .......

where xxx eq itab-xxxx.

...........

...........

MODIFY itab.

endselect.

endloop.

i know that i have to give the sy-tabix as INDEX parameter to the modify command. but i want to know why i have to do this?

cause when i debug, i follow the sy-tabix field and it have not a change in select endselect.

may the reason of the error about cursor in select and cursor effects modify command?

or why?

Thx,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Nov 19, 2009 at 08:35 AM

    Hi Techmaster,

    By writing MODIFY the ABAP processor should know what it has to modify, you should give something like index & what reocrds need to be modified.

    Hope you understood.

    Regards

    Abhii...

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 19, 2009 at 08:40 AM

    Hello,

    I guess this is because your MODIFY statement is inside the SELECT ... ENDSELECT & not inside the LOOP ... ENDLOOP.

    SAP documentation says:

    Within a LOOP loop, the INDEX addition can be ommitted. In this case the current table line of the LOOP loop is changed.

    You have to change the coding:

    DATA: v_index TYPE i.
    
    loop at itab.
    
    v_index = sy-index.
    
    select .......
    where xxx eq itab-xxxx.
    ...........
    ...........
    MODIFY itab INDEX v_index.
    endselect.
    endloop.

    BR,

    Suhas

    PS: The coding practice followed is not very performance oriented as well. May be you should have a look around in some blogs, wikis in SCN & change the code accordingly.

    Edited by: Suhas Saha on Nov 19, 2009 9:41 AM

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 19, 2009 at 08:48 AM

    The code you provided is not sufficient to propose a solution.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 19, 2009 at 09:07 AM

    Thx All.

    @ suhas saha.

    As your message if i modify it with sy-tabix taken before select loop it works fine. But i want to know or understand why it does not work without SY-TABIX parameter as INDEX. When i debug, i saw that the SY-TABIX parameter does not change.

    i know the solution of problem as you say but i only want to know the result of solution why..

    Thx,

    Add comment
    10|10000 characters needed characters exceeded

    • Hello,

      The sy-tabix values does not hold good when the modify statement is within Select..Endselect. Only when the modify statement is within LOOP...ENDLOOP you can omitt the index as it will be automatically assigned. This is the reason why the Modify statement is not able to fetch the automatic index value when within Select..Endselect unless specifically assigned.

      Vikranth