-------------------------------------2007-6-26--------------------
国内进口是指:公司购买国内厂商的东西
国外进口是指:公司购买国外厂商的东西
创建含表头的<itab>….不含表头的<itab>…..<wa>
Defining an Internal Table
根据其它的结构构造新的itab
向内表加入数据:
内表排序
使用行组的级别控制.
逐个组件的从db中读取数据
创建含表头的<itab>….不含表头的<itab>…..<wa>
data: itab_marc like marc occurs 5 with header line,
itab_marc1 like marc occurs 1,
line_marc like marc.
Defining an Internal Table
DATA itab TYPE itabtype [WITH HEADER LINE].
DATA itab LIKE itab [WITH HEADER LINE].
DATA itab [TYPE linetype|LIKE lineobj] OCCURS n
[WITH HEADER LINE].
根据其它的结构构造新的itab
data: begin of stb occurs 0.
include structure stpox.
data: smatnr like mseg-matnr,
flag.
data: end of stb.
向内表加入数据:
APPEND LINES OF <itab1> [FROM <n1>] [TO <n2>] TO <itab2>.
APPEND [<wa> TO|INITIAL LINE TO] <itab>.
INSERT [<wa> INTO|INITIAL LINE INTO] <itab> [INDEX <idx>].
INSERT LINES OF <itab1> [FROM <n1>] [TO <n2>]
INTO <itab2> [INDEX <idx>].
内表排序
SORT <itab> [<order>] [AS TEXT]
[BY <f1> [<order>] [AS TEXT] ... <fn> [<order>] [AS TEXT]].
Eg. SORT ITAB DESCENDING BY LAND WEIGHT ASCENDING.
上句话首先根据其标准关键字进行排序,然后根据定义的LAND和WEIGHT关键字进行排序
使用行组的级别控制.
<line>
FIRST 内表的第一行
LAST 内表的最后一行
NEW <F> 行组的开头,与字段<f>和<f>剩余字段中的内容相同.
Eg.
DATA: BEGIN OF LINE,
COL1 TYPE C,
COL2 TYPE I,
COL3 TYPE I,
END OF LINE.
DATA ITAB LIKE LINE OCCURS 10.
LINE-COL1 = 'A'.
DO 3 TIMES.
LINE-COL2 = SY-INDEX.
LINE-COL3 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
LINE-COL1 = 'B'.
DO 3 TIMES.
LINE-COL2 = 2 * SY-INDEX.
LINE-COL3 = ( 2 * SY-INDEX ) ** 2.
APPEND LINE TO ITAB.
ENDDO.
loop at itab into line.
write: / line-col1, line-col2, line-col3.
endloop.
clear line.
uline.
skip.
LOOP AT ITAB INTO LINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
AT END OF COL1.
SUM.
ULINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
SKIP.
ENDAT.
AT LAST.
SUM.
ULINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
ENDAT.
ENDLOOP.
逐个组件的从db中读取数据
l To <wa>
SELECT ... INTO CORRESPONDING FIELDS OF <wa> ........
l To <itab>
SELECT ... INTO CORRESPONDING FIELDS OF TABLE <itab> ........
l Add <itab>
SELECT ... APPENDING CORRESPONDING FIELDS OF TABLE <itab> ........