这个程序展现了 如何动静内表的时候 read 操作 loop 的时候 where 条件的拼接
REPORT ztest_xy6.
DATA: BEGIN OF lt_tmp OCCURS 10,
hkont TYPE char10,
sumty(2) TYPE c,
END OF lt_tmp.
DATA: ls_tmp LIKE lt_tmp,
ls_tp2 LIKE lt_tmp.
FIELD-SYMBOLS: <st_x> TYPE x.
DEFINE m_tmp.
clear lt_tmp.
lt_tmp-hkont = &1.
lt_tmp-sumty = &2.
append lt_tmp.
END-OF-DEFINITION.
m_tmp '0090020020' '22'.
m_tmp '0090020020' '21'.
m_tmp '0090010010' 'C1'.
m_tmp '0020110100' 'C1'.
ASSIGN: ls_tmp TO <st_x> CASTING.
ls_tmp-hkont = '0090020020'. ls_tmp-sumty = '22'.
DATA gt_where TYPE TABLE OF string.
gt_where = VALUE #(* ( |with key|)
(| HKONT = '0090020020' AND|)
(| SUMTY = '21'|) ).
DATA:gv_where TYPE string.
gv_where = |Hello | & |world| .
WRITE:/ gv_where.
READ TABLE lt_tmp WITH KEY <st_x>.
IF sy-subrc = 0.
WRITE: / lt_tmp-hkont,lt_tmp-sumty.
ENDIF.
LOOP AT lt_tmp WHERE (gt_where).
WRITE: / lt_tmp-hkont,lt_tmp-sumty.
ENDLOOP.