‎2008 Dec 18 11:08 AM
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
‎2008 Dec 18 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
‎2008 Dec 18 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.
‎2008 Dec 18 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
‎2008 Dec 18 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
‎2008 Dec 18 11:13 AM
have u defined calc_price as data type CURR ? Please check that .
Regards,
Ajay
‎2008 Dec 18 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.
‎2008 Dec 18 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
‎2008 Dec 18 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.
‎2008 Dec 18 11:17 AM
Use Modify with INDEX .
or use
loop at xkomv where kschl = 'EDI1'.
xkomv-kwert = calc_price.
modify xkomv.
endloop.
‎2008 Dec 18 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
‎2008 Dec 18 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.