SAP RANG语法
Range 和select-option 的变量是差不多的
sign = 'I' 或 sign = 'E' 是指INCLUED 和 EXCLUDE
OPTION = 'EQ' 或其他操作符。。
LOW 是指最少值(操作符是范围的话)
HIGH ( 如果操作符是‘EQ’,该field没用)
EX.
REPORT YPMRP001.
TABLES MARA.
DATA: N TYPE I.
DATA: N1 TYPE I.
DATA: N2 TYPE I.
"用RANGE定义的内表
RANGES S_MATNR FOR MARA-MATNR OCCURS 0.
S_MATNR-SIGN = 'I'.
S_MATNR-OPTION = 'BT'.
S_MATNR-LOW = '000000004000000041'.
S_MATNR-HIGH = '000000004000000100'.
APPEND S_MATNR.
SELECT COUNT(*) INTO N FROM MARA
WHERE MATNR IN S_MATNR.
WRITE N.
"普通方法定义的内表
DATA: BEGIN OF S_MATNR1 OCCURS 0,
SIGN TYPE C,
OPTION(2) TYPE C,
LOW LIKE MARA-MATNR,
HIGH LIKE MARA-MATNR,
END OF S_MATNR1.
S_MATNR1-SIGN = 'I'.
S_MATNR1-OPTION = 'BT'.
S_MATNR1-LOW = '000000004000000041'.
S_MATNR1-HIGH = '000000004000000100'.
APPEND S_MATNR1.
SELECT COUNT(*) INTO N1 FROM MARA
WHERE MATNR IN S_MATNR1.
WRITE N1.
"用SELECT-OPTIONS
SELECT-OPTIONS:S_MATNR2 FOR MARA-MATNR
DEFAULT '000000004000000041' TO '000000004000000100' .
SELECT COUNT(*) INTO N2 FROM MARA
WHERE MATNR IN S_MATNR2.
WRITE N2.
输出结果如下: