Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZXXX_SMARTFORM_SEARCH
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zxxx_smartform_search.
INCLUDE rstxsfxint.
DATA:
gv_found TYPE flag,
gv_start_idx TYPE sy-tabix,
gv_end_idx TYPE sy-tabix,
gs_text_key TYPE stxh_key,
gt_token TYPE t_token,
gs_form TYPE stxfadm,
gt_forms TYPE TABLE OF stxfadm.
FIELD-SYMBOLS:
<text_objekt> LIKE LINE OF t_objt,
<text_token> LIKE LINE OF t_ntokens,
<token_start> LIKE LINE OF <text_token>-t_token.
" in welchen Smartforms soll gesucht werden
SELECT-OPTIONS:
s_tdnam FOR stxfadm-formname,
s_spras FOR stxfadm-masterlang DEFAULT sy-langu.
SELECTION-SCREEN SKIP.
" gesuchter Standardtext wird mitgegeben
PARAMETERS:
p_object TYPE tdobject OBLIGATORY DEFAULT 'TEXT',
p_name TYPE tdobname OBLIGATORY,
p_id TYPE tdid OBLIGATORY DEFAULT 'ST',
p_spras TYPE spras OBLIGATORY DEFAULT sy-langu.
INITIALIZATION.
s_tdnam = 'ICPZ*'. APPEND s_tdnam.
START-OF-SELECTION.
" Header aller Formulare lesen die gewünscht sind
SELECT * FROM stxfadm
INTO TABLE gt_forms
WHERE formname IN s_tdnam
AND masterlang IN s_spras
AND formtype = ''.
LOOP AT gt_forms INTO gs_form.
CLEAR t_objt[].
" die in diesen Formularen enthalten Objekte vom Typ Text lesen
SELECT * FROM stxfobjt
INTO TABLE t_objt
WHERE langu IN s_spras
AND formname = gs_form-formname
AND objtype = c_node_text
ORDER BY langu iname. "includierte Texte
" Texte sind vorhanden
IF t_objt[] IS NOT INITIAL.
" Clusterinformationen Zum Formular lesen
IMPORT t_ntokens FROM DATABASE stxfcont(xx) ID gs_form-formname
IGNORING CONVERSION ERRORS.
" alle Textknoten befinden sich im Eintrag vom Typ C_NODE_TEXT
READ TABLE t_ntokens ASSIGNING <text_token>
WITH KEY ntype = c_node_text.
" pro Textobjekt ein Eintrag in t_objt
LOOP AT t_objt ASSIGNING <text_objekt>.
" Bereich zum Text aus der Tokentabelle bestimmen
READ TABLE <text_token>-t_token TRANSPORTING NO FIELDS
WITH KEY ttype = c_ttype_node_begin
tname = <text_objekt>-iname.
gv_start_idx = sy-tabix.
READ TABLE <text_token>-t_token TRANSPORTING NO FIELDS
WITH KEY ttype = c_ttype_node_end
tname = <text_objekt>-iname.
gv_end_idx = sy-tabix.
" handelt es sich um einen inkludierten Standardtext
LOOP AT <text_token>-t_token TRANSPORTING NO FIELDS
FROM gv_start_idx TO gv_end_idx
WHERE tname = 'TTYPE'
AND value = c_ttype_include. " Textinclude
ENDLOOP.
IF sy-subrc = 0.
"Standardtext inkludiert
CLEAR gs_text_key.
READ TABLE <text_token>-t_token
TRANSPORTING NO FIELDS
WITH KEY ttype = c_ttype_value
tname = 'OBJECT'
value = p_object.
IF sy-subrc = 0 AND sy-tabix < gv_end_idx.
" Objekt in Ordnung
gs_text_key-tdobject = p_object.
READ TABLE <text_token>-t_token
TRANSPORTING NO FIELDS
WITH KEY ttype = c_ttype_value
tname = 'NAME'
value = p_name.
IF sy-subrc = 0 AND sy-tabix < gv_end_idx.
" Textname in Ordnung
gs_text_key-tdname = p_name.
READ TABLE <text_token>-t_token
TRANSPORTING NO FIELDS
WITH KEY ttype = c_ttype_value
tname = 'ID'
value = p_id.
IF sy-subrc = 0 AND sy-tabix < gv_end_idx.
" ID in Ordnung
gs_text_key-tdid = p_id.
READ TABLE <text_token>-t_token
TRANSPORTING NO FIELDS
WITH KEY ttype = c_ttype_value
tname = 'LANG'
value = p_spras.
IF sy-subrc = 0 AND sy-tabix < gv_end_idx.
" Sprache in Ordnung
gs_text_key-tdspras = p_spras.
ELSE.
" Sprache passt nicht
" interessieren nicht mehr
IF gv_start_idx > 0.
DELETE <text_token>-t_token FROM gv_start_idx TO gv_end_idx.
ENDIF.
CONTINUE.
ENDIF.
ELSE.
" ID passt nicht
" interessieren nicht mehr
DELETE <text_token>-t_token FROM gv_start_idx TO gv_end_idx.
CONTINUE.
ENDIF.
ELSE.
" Textname passt nicht
" interessieren nicht mehr
IF gv_start_idx > 0.
DELETE <text_token>-t_token FROM gv_start_idx TO gv_end_idx.
ENDIF.
CONTINUE.
ENDIF.
ELSE.
" Objekt passt nicht
" interessieren nicht mehr
IF gv_start_idx > 0.
DELETE <text_token>-t_token FROM gv_start_idx TO gv_end_idx.
ENDIF.
CONTINUE.
ENDIF.
ELSE.
" interessieren nicht mehr
IF gv_start_idx > 0.
DELETE <text_token>-t_token FROM gv_start_idx TO gv_end_idx.
ENDIF.
CONTINUE.
ENDIF.
" Treffer, gs_text_key muss hier komplett gefüllt sein
WRITE: / 'Formular/Sprache', <text_objekt>-formname, '/',
<text_objekt>-langu, 'Text gefunden', p_id, p_object, p_name, p_spras.
" interessieren nicht mehr
IF gv_start_idx > 0.
DELETE <text_token>-t_token FROM gv_start_idx TO gv_end_idx.
ENDIF.
CONTINUE.
ENDLOOP.
ENDIF.
ENDLOOP.