1. TYPES : 선언 만되고 개체가 생성은 되지 않음
TYPES : BEGIN OF line,
col1(10) TYPE c,
col2(10) TYPE c,
END OF line.
DATA itab TYPE TABLE OF line WITH HEADER LINE. "OK
*DATA itab LIKE TABLE OF line WITH HEADER LINE. " ERROR
=> LIKE의 data(개체)로 선언되어 진 것만 사용 가능하다.
다음과 같이 작성해야 한다.
types : BEGIN OF str,
col1(10) TYPE c,
col2(10) TYPE c,
END OF str.
data: line type str. " DATA 개체가 생성
DATA: itab LIKE table of line WITH HEADER LINE. " 생성된 개체를 참조*DATA: itab type TABLE OF line WITH HEADER LINE.
2. DATA : 선언과 동시에 객체도 생성됨
data : BEGIN OF line,
col1(10) TYPE c,
col2(10) TYPE c,
END OF line.
DATA: itab LIKE table of line WITH HEADER LINE. "OK
DATA itab type TABLE OF line WITH HEADER LINE. "OK
----------------------------------------------------------------------------------------------------------------------
==실행 TEST SOURCE==
*itab-col1 = 'a'.
line-col1 = 'kim'. line-col2 = 'eunjeong'.
append line to itab.
*INSERT table itab.
line-col1 = 'park'. line-col2 = 'youngha'.
append line to itab.
*INSERT table itab.
LOOP AT itab into line.
WRITE :/ line-col1, line-col2.
ENDLOOP.