Code: Alles auswählen.
*Filtertabelle - Prämisse: Feld ist namensgleich zu Spalte in itab
data: begin of filter occurs 100,
feld type dd03l-fieldname,
von type string,
bis type string,
end of filter.
DATA: BEGIN OF PROG OCCURS 0,
LINE(72) TYPE C,
END OF PROG.
DATA GENPROG LIKE TADIR-OBJ_NAME.
DATA LINE TYPE I.
DATA WORD(80) TYPE C.
DATA MESSAGE(99) TYPE C.
DATA ERROR.
data z(5).
include zfilteri1."hier ist itab deklariert !!!
data htab like itab occurs 0 with header line. "Kopie von itab
*Programm create
append 'REPORT ZFILTER01.' to prog.
concatenate 'include' 'ZFILTERI1.' into prog-line separated by space.
append prog.
*Upro create
append 'form filter_itab tables tab structure itab' to prog.
append ' htab structure itab.' to prog.
append 'loop at tab' to prog.
*where clause
loop at filter where von <> space and bis <> space.
add 1 to z.
if z = 1.
concatenate 'where' filter-feld 'between' filter-von
'and' filter-bis into prog-line separated by space.
append prog.
else.
concatenate 'and' filter-feld 'between' filter-von
'and' filter-bis into prog-line separated by space.
append prog.
endif.
endloop.
*Punkt nicht vergessen...
append '.' to prog.
*Übegabe an htab
append 'append tab to htab.' to prog.
*Ende loop / upro.
append 'endloop.' to prog.
append 'endform.' to prog.
*GENERIERUNG + ENDE Quellcodeerzeugung
GENERATE SUBROUTINE POOL PROG NAME GENPROG MESSAGE MESSAGE
LINE LINE WORD WORD.
*evtl. Fehlerausgabe
IF SY-SUBRC <> 0.
ERROR = SY-SUBRC.
LOOP AT PROG.
WRITE: / SY-TABIX.
IF SY-TABIX = LINE .
WRITE: PROG COLOR 6.
WRITE:/ LINE , MESSAGE COLOR 6 INTENSIFIED OFF.
ELSE.
WRITE: PROG.
ENDIF.
ENDLOOP.
ENDIF.
*nur weiter wenn upro o.k.
check error is initial.
*filtern von itab
PERFORM filter_itab IN PROGRAM (GENPROG) tables itab htab.
Code: Alles auswählen.
loop at ftab.
replace ',' with ' BETWEEN ' into ftab.
replace ',' with ' AND ' into ftab.
if sy-tabix ne 1.
concatenate 'AND' ftab into ftab separated by space.
endif.
modify ftab.
endloop.
select * from ztab where (ftab).
Code: Alles auswählen.
ranges rzahl for itab-zaehler.
ranges rpreis for itab-preis.
loop at filtertab.
case filtertab-feldname.
when 'Zähler'.
rzahl-sign = 'I'.
rzahl-option = 'BT'.
rzahl-low = filtertab-von.
rzahl-high = filtertab-bis.
append rzahl.
when 'Preis'.
"s.o. nur mit Preis
endcase.
endloop.
loop at itab.
check not itab-zaehler in rzahl.
check not itab-preis in rpreis.
delete itab.
endloop.
Code: Alles auswählen.
if filter-von is initial.
concatenate 'ITAB-' filter-feld into hfeld.
assign (hfeld) to <f>.
describe field <f> type typ.
case typ.
when 'P'.
<f> = 0."Startwert filter-von in Where-clause ersetzen
* when....
when others.
endcase.
endif.