1. Heaer 가 있는 internal table 사용
: ABAP에 객체지향 개념이 도입되면서 Header Line이 지원되지 않으며 , Occurs 구문을 포함하여
Header line이 존재하는 Internal Table을 사용하지 말 것을 권하고 있다.
------------------------------------------------------------------------------------------------------------
TYPES: BEGIN OF line,
col1 TYPE I,
col2 TYPE I,
END OF line.
DATA itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1
WITH HEADER LINE.
DO 4 TIMES.
itab-col1 = sy-Index.
itab-col2 = sy-Index ** 2.
INSERT Table itab.
ENDDO.
itab-col1 = 2.
READ TABLE itab FROM itab.
itab-col2 = 100.
MODIFY TABLE itab.
itab-col1 = 4.
DELETE TABLE itab.
LOOP AT itab.
WRITE: / itab-col1, itab-col2.
ENDLOOP.
TYPES: BEGIN OF line,
col1 TYPE I,
col2 TYPE I,
END OF line.
2. header가 없는 wa(work area)를 사용
----------------------------------------------------------------------------------
DATA itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1.
* Work Area 생성
DATA wa LIKE LINE OF itab.
DO 4 TIMES.
wa-col1 = sy-Index.
wa-col2 = sy-Index ** 2.
INSERT wa INTO TABLE itab.
ENDDO.
wa-col1 = 2.
READ TABLE itab FROM wa INTO wa.
wa-col2 = 100.
MODIFY TABLE itab FROM wa.
wa-col1 = 4.
DELETE TABLE itab FROM wa.
LOOP AT itab INTO wa.
WRITE: / wa-col1, wa-col2.
ENDLOOP.
출처 : EASY ABAP