2007 Jul 19 3:52 PM
Hi all,
I have to place a value in a perticuler row of an internal table.
Based on condition.
How to modify the internal table.
ex
matnr werks maktx
0001 0008 khga
0002 0098
in this i want to place a value in second record(in 2nd row of MAKTX) based on condition MATNR and WERKS, .
kishi.
2007 Jul 19 3:54 PM
read table itab with key matnr = <material>
werks = <Plant>.
if sy-subrc = 0.
itab-maktx = 'New value'.
modify itab index sy-tabix.
endif.
2007 Jul 19 3:55 PM
use READ table option
READ TABLE ITAB INTO WA_ITAB WITH KEY MATNR = V_MATNR
WERKS = V_WERKS.
IF SY-SUBRC EQ 0.
WA_ITAB-MAKTX = 'XXXXXXX'.
MODIFY ITAB FROM WA_ITAB.
ENDIF.
2007 Jul 19 3:55 PM
Hi,
Set the variable with the value u want and then use modify statement.
itab-maktx = 'Changed value1'.
modify itab transporting maktx where matnr = '1000' and werks = '0100'.
2007 Jul 19 3:57 PM
Loop at itab.
if itab-matnr = '0002'
and itab-werks = '0098'.
itab-maktx = 'This Value'.
modify itab.
endloop.
Or....
Read table itab with key matnr = '0002'
werks = '0098'.
if sy-subrc = 0.
itab-maktx = 'This Value'.
modify itab index sy-tabix.
endif.
Or...
Read table itab index 2
if sy-subrc = 0.
itab-maktx = 'This Value'.
modify itab index sy-tabix.
endif.
Regards
Rich Heilman