Open SQL能够动态定义WHERE条件。如下:
[For Example]
DATA: WHERE_TAB TYPE TABLE OF EDPLINE.
DATA: DT_SCUSTOM LIKE STANDARD TABLE OF SCUSTOM WITH HEADER LINE.
APPEND ' ID = 11279 ' TO WHERE_TAB. "添加条件
APPEND ' OR ' TO WHERE_TAB.
APPEND ' ID = 36 ' TO WHERE_TAB.
*DATA COND TYPE STRING.
*LOOP AT WHERE_TAB INTO COND. "无HEADER LINE内表LOOP...INTO FIELD
"WRITE: / COND.
*ENDLOOP.
SELECT ID NAME FROM SCUSTOM INTO CORRESPONDING FIELDS OF DT_SCUSTOM WHERE (WHERE_TAB).
WRITE:/ DT_SCUSTOM.
ENDSELECT.
*运行结果如下:
SELECT * FROM SCUSTOM INTO DT_SCUSTOM WHERE (WHERE_TAB).
WRITE:/ DT_SCUSTOM.
ENDSELECT.
*运行结果如下: