Application Development and Automation 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: 
Read only

Modify?

Former Member
0 Kudos
194

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
Read only

Former Member
0 Kudos
163

read table itab with key matnr = <material>

werks = <Plant>.

if sy-subrc = 0.

itab-maktx = 'New value'.

modify itab index sy-tabix.

endif.

Read only

Former Member
0 Kudos
163

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.

Read only

former_member491305
Active Contributor
0 Kudos
163

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

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
163


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