EX1)
TYPES: BEGIN OF mytext,
number TYPE i,
name(10) TYPE c,
END OF mytext.
TYPES mytab TYPE STANDARD TABLE OF mytext WITH DEFAULT KEY.
DATA text TYPE mytext.
DATA itab TYPE mytab.
text-number = 1. text-name = 'John'.
APPEND text TO itab.
text-number = 2. text-name = 'Paul'.
APPEND text TO itab.
text-number = 3. text-name = 'Ringo'.
APPEND text TO itab.
text-number = 4. text-name = 'George'.
APPEND text TO itab.
LOOP AT itab INTO text.
WRITE: / text-number,text-name.
ENDLOOP.
EX2)
DATA: BEGIN OF line,
land(3) TYPE c,
name(10) TYPE c,
age TYPE i,
weight TYPE p DECIMALS 2,
END OF line.
DATA itab LIKE SORTED TABLE OF line
WITH NON-UNIQUE KEY land name age weight.
line-land = 'G'. line-name = 'Hans'.
line-age = 20. line-weight = '80.00'.
INSERT line INTO TABLE itab.
line-land = 'USA'. line-name = 'Nancy'.
line-age = 35. line-weight = '45.00'.
INSERT line INTO TABLE itab.
line-land = 'USA'. line-name = 'Howard'.
line-age = 40. line-weight = '95.00'.
INSERT line INTO TABLE itab.
LOOP AT itab INTO line.
WRITE: / line-land, line-name, line-age, line-weight.
ENDLOOP.
EX3)
DATA: BEGIN OF line,
col1 TYPE i,
col2 TYPE i,
END OF line.
DATA: itab LIKE STANDARD TABLE OF line,
jtab LIKE SORTED TABLE OF line
WITH NON-UNIQUE KEY col1 col2.
DO 3 TIMES.
line-col1 = sy-index. line-col2 = sy-index ** 2.
APPEND line TO itab.
line-col1 = sy-index. line-col2 = sy-index ** 3.
APPEND line TO jtab.
ENDDO.
INSERT LINES OF itab INTO TABLE jtab.
LOOP AT jtab INTO line.
WRITE: / sy-tabix, line-col1, line-col2.
ENDLOOP.
EX4)
DATA: BEGIN OF line,
col1(1) TYPE c,
col2(1) TYPE c,
END OF line.
DATA: etab LIKE TABLE OF line WITH HEADER LINE,
ftab1 LIKE TABLE OF line.
line-col1 = 'A'. line-col2 = 'B'.
APPEND line TO etab.
MOVE etab[] TO ftab1.
LOOP AT ftab1 INTO line.
WRITE: / line-col1, line-col2.
ENDLOOP.
SKIP.
ULINE.
EX5)
DATA: BEGIN OF line,
col1(1) TYPE c,
col2(1) TYPE c,
END OF line.
DATA itab LIKE TABLE OF line.
line-col1 = 'A'. line-col2 = 'B'.
APPEND line TO itab.
REFRESH itab.
IF itab IS INITIAL.
WRITE 'ITAB is empty'.
FREE itab.
ENDIF.
빨간 줄 친 부분의 뜻이 이해가 가지 않습니다....
도와주세요
1. TYPES mytab TYPE STANDARD TABLE OF mytext WITH DEFAULT KEY.
=>mytab을 mytext 형태의 테이블로 선언하는 데 name 필드를 키로 해서 선언(Default key는 C 타입이 모두 키가 된다)
2. APPEND text TO itab.
=>text의 내용을 itab에 insert 한다
3. DATA itab LIKE SORTED TABLE OF line WITH NON-UNIQUE KEY land name age weight.
=> itab을 line 타입의 정렬된 테이블로 선언하는 데 key 이하 필드의 유니크함은 적용하지 않는다
즉 sorted 테이블은 key를 지정하게 되는 데 위의 선언은 이런 키가 필요없다는 뜻
4. INSERT line INTO TABLE itab.
=> 2번과 동일함. 다른점은 itab 에 저장위치가 다르다는 점
5. MOVE etab[] TO ftab1.
=> etab의 body에 있는 내용을 ftab1에 복사(이때 두 인터널 테이블의 구조는 같아야함)
6.SKIP. => 한줄 띄우기
ULINE. => Underline
더 자세한 사항은 해당 코드에서 F1