Internal Tables 9
Internal Tables 9
Append: - Append is the keyword to transfer the data from work area to at the last record of internal table.
Syntax: -
Append <work area> to <internal table>.
Example on append
REPORT YSP_7PM_OITAB_OPERATIONS.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE IT_T001 UP TO 5 ROWS.
Insert: - Insert is the keyword to transfer the data from work area to internal table based on the key
field.
Syntax: -
Insert <work area> into table <internal table>.
Ex: -
Insert WA_t001 into table IT_t001.
Note: - If we use insert keyword to standard internal table then it acts like append.
Example on insert
REPORT YSP_7PM_OITAB_OPERATIONS.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE IT_T001 UP TO 5 ROWS.
Collect: - Collect checks the internal table whether the record is available or not based on the key field.
If not it acts like append (record adds first). Other wise it adds the numeric fields from work area to
number field in the internal table.
Syntax: -
Collect <Workarea> into <Internal table>.
Example on collect
REPORT YSP_7PM_OITAB_OPERATIONS.
WA-EID = '1'.
WA-EBO = '5000'.
COLLECT WA INTO IT.
WA-EID = '2'.
WA-EBO = '9000'.
COLLECT WA INTO IT.
WA-EID = '4'.
WA-EBO = '2000'.
COLLECT WA INTO IT.
LOOP AT IT INTO WA.
WRITE :/ WA-EID,WA-EBO.
ENDLOOP.
ULINE.
*Collect
WA-EID = '3'.
WA-EBO = '7000'.
COLLECT WA INTO IT.
WA-EID = '2'.
WA-EBO = '6000'.
COLLECT WA INTO IT.
REPORT YSP_7PM_OITAB_OPERATIONS.
Ex: -
Read table IT_t001 into WA_t001 with key BUKRS = ‘2000’.
OP: - 1000 IBM Chennair
Ex:-
Read table IT_t001 into WA_t001 with key ort01 = ‘Hyd’.
Ex: -
Loop at IT_t001 into WA_t001 where ORT01 = ‘Hyderabad’.
Write: / WA_t001-BUKRS, WA_t001-BUTXT, WA_t001-ORT01.
Endloop.
OP: - 1000 TCS Hyderabad
3000 HCL Hyderabad