ABAP顾问
分类:
2008-04-26 17:37:06
REPORT z_barry_test. "TEST
TABLES mara.
RANGES itab FOR mara-matnr OCCURS 0. "或者如下面定义方法
* DATA itab TYPE RANGE OF mara-matnr WITH HEADER LINE .
DATA: BEGIN OF itab2 OCCURS 0,
sign TYPE c ,
option(2) TYPE c ,
low LIKE mara-matnr ,
high LIKE mara-matnr ,
END OF itab2.
DATA: n TYPE i.
SELECT-OPTIONS:s_matnr FOR mara-matnr
DEFAULT '000000000000317030' TO '000000000000317045' .
START-OF-SELECTION.
*用SELECT-OPTIONS
SELECT COUNT(*) INTO n FROM mara
WHERE matnr IN s_matnr.
WRITE n.
*用Range定义的内表
itab-sign = 'I'.
itab-option = 'BT'.
itab-low = '000000000000317030'.
itab-high = '000000000000317045'.
APPEND itab.
SELECT COUNT(*) INTO n FROM mara
WHERE matnr IN itab.
WRITE n.
*普通方法定义的内表
itab2-sign = 'I'.
itab2-option = 'BT'.
itab2-low = '000000000000317030'.
itab2-high = '000000000000317045'.
APPEND itab2.
SELECT COUNT(*) INTO n FROM mara
WHERE matnr IN itab2.
WRITE n.