ABAP 动态查询条件

REPORT demo_select_dynamic_conditions .

DATA: cond(72) TYPE c,
itab LIKE TABLE OF cond.

PARAMETERS: city1(10) TYPE c, city2(10) TYPE c.

DATA wa TYPE spfli-cityfrom.

CONCATENATE'CITYFROM = ''' city1 ''''INTO cond.
APPEND cond TO itab.
CONCATENATE'OR CITYFROM = ''' city2 ''''INTO cond.
APPEND cond TO itab.
CONCATENATE'OR CITYFROM = ''' 'BERLIN' ''''INTO cond.
APPEND cond TO itab.

LOOP AT itab INTO cond.
WRITE cond.
ENDLOOP.

SKIP.

SELECT cityfrom
INTO wa
FROM spfli
WHERE (itab).

WRITE / wa.

ENDSELECT.

ABAP 动态查询条件_第1张图片

ABAP 动态查询条件_第2张图片

REPORT demo_select_dynamic_conditions .

DATA: cond(72) TYPE c,
itab LIKE TABLE OF cond.

PARAMETERS: city1(10) TYPE c, city2(10) TYPE c.

DATA wa TYPE spfli-cityfrom.

CONCATENATE'CITYFROM = ''' city1 ''''INTO cond.
APPEND cond TO itab.
CONCATENATE'OR CITYFROM = ''' city2 ''''INTO cond.
APPEND cond TO itab.
CONCATENATE'OR CITYFROM = ''' 'BERLIN' ''''INTO cond.
APPEND cond TO itab.

LOOP AT itab INTO cond.
WRITE cond.
ENDLOOP.

SKIP.

SELECT cityfrom
INTO wa
FROM spfli
WHERE (itab).

WRITE / wa.

ENDSELECT.

ABAP 动态查询条件_第3张图片

ABAP 动态查询条件_第4张图片

你可能感兴趣的:(abap)