INSERT: -
Insert is the keyword to transfer the data from work area to internal table based on the key field.
Syntax: - Insert <wa> into table <it>.
Ex: -
Insert WA into table IT.
Note: - If we use insert keyword to standard internal table then it acts like append.
PROGRAM:
*&---------------------------------------------------------------------*
*& Report ZR_INSERT_KEYWORD
*&
*&---------------------------------------------------------------------*
REPORT ZR_INSERT_KEYWORD.
Types: begin of ty,
Eid(10) type C,
Ename(25) type C,
End of ty.
Data WA type ty.
Data IT like sorted table of WA with unique key Eid.
WA-Eid = '1'.
WA-Ename = 'Vidya'.
Insert WA into table IT.
WA-Eid = '3'.
WA-Ename = 'Latha'.
Insert WA into table IT.
Loop at IT into WA.
Write : / WA-Eid, WA-Ename.
Endloop.
Uline.
WA-Eid = '2'.
WA-Ename = 'Satiah'.
Insert WA into table IT.
Loop at IT into WA.
Write: / WA-Eid, WA-Ename.
Endloop.
Insert is the keyword to transfer the data from work area to internal table based on the key field.
Syntax: - Insert <wa>
*& Report ZR_INSERT_KEYWORD
*&
*&---------------------------------------------------------------------*
REPORT ZR_INSERT_KEYWORD.
Types: begin of ty,
Eid(10) type C,
Ename(25) type C,
End of ty.
Data WA type ty.
Data IT like sorted table of WA with unique key Eid.
WA-Eid = '1'.
WA-Ename = 'Vidya'.
Insert WA into table IT.
WA-Eid = '3'.
WA-Ename = 'Latha'.
Insert WA into table IT.
Loop at IT into WA.
Write : / WA-Eid, WA-Ename.
Endloop.
Uline.
WA-Eid = '2'.
WA-Ename = 'Satiah'.
Insert WA into table IT.
Loop at IT into WA.
Write: / WA-Eid, WA-Ename.
Endloop.