Skip to Content
-1
Oct 23, 2019 at 11:50 AM

NEW INSERT WITH MODIFY

116 Views

Hi i am new to SAP have a doubt , can anyone clarify it.. I have this program

Here need to change Pname(record from AC TO TC) i used modify but not working...

TYPES: BEGIN OF ty_product,

pid(10) TYPE c,

pname(20) TYPE c,

pamount TYPE i,

END OF ty_product.

DATA: it TYPE TABLE OF ty_product,

wa TYPE ty_product. DATA:

gv_tabix TYPE sy-tabix.

* Index1 wa-pid = 'IFB1'.

wa-pname = 'WASHING MACHINE'.

wa-pamount = 31000.

INSERT wa INTO TABLE it. *

Index2 wa-pid = 'IFB2'.

wa-pname = 'FRIDGE'.

wa-pamount = 32000.

INSERT wa INTO TABLE it.

*Index3 wa-pid = 'IFB3'.

wa-pname = 'AC'.

wa-pamount = 35000.

INSERT wa INTO TABLE it.

LOOP AT it INTO wa.

IF sy-subrc = 0.

gv_tabix = sy-tabix.

MODIFY it FROM wa INDEX gv_tabix TRANSPORTING pname .

wa-pname = 'TV'. * MODIFY it FROM wa INDEX 3 TRANSPORTING pname.

* READ TABLE it INTO wa INDEX gv_tabix.

* MODIFY it FROM wa INDEX 3 TRANSPORTING pname .

WRITE: / wa-pid , wa-pname , wa-pamount.

ELSE.

WRITE: 'No record found'.

ENDIF.

ENDLOOP.