Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Modify?

Former Member
0 Kudos
136

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.

4 REPLIES 4

former_member181962
Active Contributor
0 Kudos
105

read table itab with key matnr = <material>

werks = <Plant>.

if sy-subrc = 0.

itab-maktx = 'New value'.

modify itab index sy-tabix.

endif.

Former Member
0 Kudos
105

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.

former_member491305
Active Contributor
0 Kudos
105

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

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
105


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