内表 abap
内表相关的要点包括:
内表种类(标准表、排序表、哈希表);
行结构(参考字段、参考类型);
表关键字(With key);
初始内存大小。
" 1) data BEGIN OF itab OCCURS n,END OF itab
DATA: BEGIN OF itab_test OCCURS 0, " 定义了一个有表头的内表
matnr(04) TYPE C,
ebeln TYPE I,
END OF itab_test.
TYPES: BEGIN OF itab_c,
aaa TYPE I,
bbb(20) TYPE C,
END OF itab_c.
" 2) DATA itab LIKE RANGE OF itab
DATA: ITAB1 LIKE RANGE OF MARA-MATNR. " 定义一个表,结构为ranges ,有上下限
" 3) RANGES itab FOR itab
RANGES: s_bwart FOR mseg-bwart.
" 4) data like
DATA tlike LIKE itab_test. " 定义一个结构
DATA tlike_occurs0 LIKE itab_test OCCURS 0. " 定义一个无表头的内表
DATA tlike_occurs0_withhead LIKE itab_test OCCURS 0 WITH HEADER LINE. " 定义一个有表头的内表
" 5) data like line of
DATA: like_lof LIKE LINE OF itab_test, " 定义一个结构
like_lof _occurs0 LIKE line of itab_test OCCURS 0, " 定义一个无表头的内表
like_lof _occurs0_nohead LIKE LINE OF itab_test OCCURS 0 WITH HEADER LINE. " 定义一个有表头的内表
" 6) data like table of 只能跟内表,不能跟结构、工作区
DATA lt LIKE TABLE OF itab_test . " 定义了一个参照有表头内表的内表,但不带工作区
*DATA lt_occurs0 LIKE TABLE OF itab_test OCCURS 0. 错误定义,不可带OCCURS 0。
DATA lt_withhead LIKE TABLE OF itab_test WITH HEADER LINE. " 定义一个有表头的内表。
" 7) INCLUDE STRUCTURE 可以跟表、结构、内表
TYPES: BEGIN OF t_display.
INCLUDE STRUCTURE ZTFICO_PPS. “如果是表类型的,需要使用include type xxx.
TYPES: SEL,
ZNUM TYPE ZNUM,
field_style TYPE LVC_T_STYL,
END OF t_display.