Skip to Content
author's profile photo Former Member
Former Member

Modify statement

Hi all,

I have a problem with the modify statement. I have declared an internal table xkomv:

data:begin of xkomv occurs 0.

include structure komv.

data : end of xkomv.

data : calc_price like komv-kwert.

read table xkomv with key kschl = 'EDI1'.

xkomv-kwert = calc_price.

modify xkomv.

after this modify statement... I am getting a dump. Please tell me if there is anything wrong in the statement.

Thanks,

archana

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

10 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:20 AM

    You CAN use the MODIFY statement after a READ as well as within a LOOP. You don't need to use TRANSPORTING either.

    Your code should look like this:

    READ TABLE xkomv WITH KEY kschl = 'EDI1'.
    IF sy-subrc EQ 0.
      xkomv-kwert = calc_price.
      MODIFY xkomv INDEX sy-tabix.
    ENDIF.
    

    This will only change the first entry it finds, if you need to change more than one entry:

    LOOP AT xkomv WHERE kschl EQ 'EDI1'.
      xkomv-kwert = calc_price.
      MODIFY xkomv.
    ENDLOOP.
    

    Notice, you don't need INDEX inside a LOOP.

    Edited by: Gill Ackroyd on Dec 18, 2008 11:21 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 18, 2008 at 11:10 AM

    hi,

    try this.

    
    read table xkomv with key kschl = 'EDI1'.
    if sy-subrc = 0.
    xkomv-kwert = calc_price.
    endif.
    modify xkomv transporting kwert.
    
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:10 AM

    Hi Archana,

    You need to use Index for modify.

    Change the code as below.

    read table xkomv with key kschl = 'EDI1'.
    If sy-subrc eq 0.
    xkomv-kwert = calc_price.
    modify xkomv index sy-tabix 
                         transporting kwert.
    endif.
    

    This should work.

    Best Regards,

    Ram.

    Edited by: ram Kumar on Dec 18, 2008 12:10 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:12 AM

    Hi you have to use MODIFY in loop only.

    loop at itab into wa.

    wa-num = '10'.

    modify itab from wa.

    endloop.

    Regards,

    Ajay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:13 AM

    have u defined calc_price as data type CURR ? Please check that .

    Regards,

    Ajay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:14 AM

    Hi,

    Here u have to use the index and transporting statement

    e.g modify xkomv index (row no) transporting kwert.

    Here u can also use sytabix....

    data : mytabix type sy-tabix.

    read table xkomv with key kschl = 'EDI1'.

    mytabix = sy-tabix.

    xkomv-kwert = calc_price.

    modify xkomv index mytabix.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 18, 2008 at 11:14 AM

    Hi Archana,

    while using MODIFY statement you need to specify the index else system treats index as 0,

    which results in short dump.

    you need to modify the itab in the loop only

    loop at itab.

    modify itab index sy-tabix.

    endloop

    if you are using a READ key word

    data tabix type sy-tabix.

    loop at itab.

    tabix = sy-tabix.

    read table itab -


    modify itab index tabix." since sy-tabix changes from loop and then in the read statement

    endloop

    Regards

    Ramchander Rao.K

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:15 AM

    read table xkomv with key kschl = 'EDI1'.

    if sy-subrc = 0.

    xkomv-kwert = calc_price.

    modify xkomv index sy-tabix..

    endif.

    or its better to use field-symbols.

    read table xkomv with key kschl = 'EDI1' assigning <fs_komv>

    if sy-subrc = 0.

    <fs_komv>-kwert = calc_price.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:17 AM

    Use Modify with INDEX .

    or use

    loop at xkomv where kschl = 'EDI1'.
     xkomv-kwert = calc_price.
     modify xkomv.
    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:33 AM

    You dont need to use any extensions of MODIFY statement.

    Just put a sy-subrc check after your read statement.

    You got a dump because no value must have been read and you used Modify.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.