LT_WHERE-WHERE_TAB sieht so ähnlich aus:*Aufbau der Ranges
LOOP AT LT_T1 INTO LV_T1.
LV_RTAB-LOW = LV_T1-FeldX.
LV_RTAB-SIGN = 'I'.
LV_RTAB-OPTION = 'EQ'.
APPEND LV_RTAB TO LT_RTAB.
ENDLOOP.
*
*Hier fehlen ein paar umformungen... die LT_RTAB wird
*einfach in eine tiefe Struktur gepackt.
*
*Convert RANGE table to WHERE-clause
CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
EXPORTING
FIELD_RANGES = LT_RANGES
IMPORTING
WHERE_CLAUSES = LT_WHERE.
*Select
SELECT
Key1
Key2
Key3
Feld1
Feld2
FROM T2 INTO TABLE LT_T2
WHERE (LT_WHERE-WHERE_TAB).
Code: Alles auswählen.
DATA: lt_ref TYPE REF TO data.
DATA: BEGIN OF lt_range OCCURS 0,
sign TYPE c LENGTH 1,
option TYPE c LENGTH 2,
low LIKE BKPF-BELNR,
high LIKE BKPF-BELNR,
END OF lt_range.
FIELD-SYMBOLS: <lft_bkpf> TYPE table,
<lft_bseg> TYPE table,
<lfs_bkpf> TYPE ANY,
<lf_belnr> TYPE ANY.
CREATE DATA lt_ref TYPE STANDARD TABLE OF ('BKPF') WITH DEFAULT KEY.
ASSIGN lt_ref->* TO <lft_bkpf>.
SELECT * FROM bkpf up to 10 ROWS INTO TABLE <lft_bkpf>.
LOOP AT <lft_bkpf> ASSIGNING <lfs_bkpf>.
ASSIGN COMPONENT 'BELNR' OF STRUCTURE <lfs_bkpf> TO <lf_belnr>.
CLEAR lt_range.
MOVE <lf_belnr> TO lt_range-low.
lt_range-sign = 'I'.
lt_range-option = 'EQ'.
APPEND lt_range.
ENDLOOP.
CREATE DATA lt_ref TYPE STANDARD TABLE OF ('BSEG') WITH DEFAULT KEY.
ASSIGN lt_ref->* TO <lft_bseg>.
SELECT * FROM BSEG INTO TABLE <lft_bseg> WHERE belnr IN
lt_range[].