一. APPEND LINE
格式: APPEND [<work area> TO ] <internal table>.
舉例一. (使用work area)
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE LINE OCCURS 10.
DO 2 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
LOOP AT ITAB INTO LINE.
WRITE: / LINE-COL1, LINE-COL2.
ENDLOOP.
執行結果為:
1 1
2 4
舉例二. (不使用work area)
DATA: BEGIN OF ITAB OCCURS 10,
COL1 TYPE I,
COL2 TYPE I,
END OF ITAB.
DO 2 TIMES.
ITAB-COL1 = SY-INDEX.
ITAB-COL2 = SY-INDEX ** 2.
APPEND ITAB.
ENDDO.
LOOP AT ITAB.
WRITE: / ITAB-COL1, ITAB-COL2.
ENDLOOP.
執行結果与舉例一相同.
舉例三. (加入另一個Internal table的元素)
格式: APPEND LINES OF <itab1> [FROM <n1> ] [TO <n2>] TO <itab2>.
將<itab1>的元素加入至<itab2>中,可選取自<n1>至<n2>的范圍.
APPEND LINES OF ITAB TO JTAB.
你可以通过这个链接引用该篇文章:http://boxman2000.bokee.com/viewdiary.10575136.html