F Modify Internal table record using Field Symbol | CodeTheta

Modify Internal table record using Field Symbol

March 07, 2020

Code :
REPORT ZVP_FIELD_SYMBOL_PROG.

TYPES: BEGIN OF STRC,
  ID TYPE I,
  NAME TYPE CHAR10,
  COUNTRY TYPE CHAR10,
  END OF STRC.

DATA: IT TYPE TABLE OF STRC,
      WA TYPE STRC.

FIELD-SYMBOLS: <WA> TYPE STRC.

WA-ID = 1.
WA-NAME = 'SOUMYO'.
WA-COUNTRY = 'INDIA'.
APPEND WA TO IT.

WA-ID = 2.
WA-NAME = 'SUVA'.
WA-COUNTRY = 'BRAZIL'.
APPEND WA TO IT.

WA-ID = 3.
WA-NAME = 'SHAROD'.
WA-COUNTRY = 'KENYA'.
APPEND WA TO IT.

READ TABLE IT ASSIGNING <WA> INDEX 3.
IF <WA> IS ASSIGNED.
<WA>-ID = 3.
<WA>-NAME = 'SHAROD1'.
<WA>-COUNTRY = 'UK'.
ENDIF.

LOOP AT IT INTO WA.
WRITE:/ WA-ID,
        WA-NAME,
        WA-COUNTRY.
ENDLOOP.

Output :


IDE Used To Test This Code : ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment