REPORT y_bc001_text_search.
TABLES: tadir.
SELECT-OPTIONS: s_devc FOR tadir-devclass DEFAULT 'Z*' OPTION CP.
SELECT-OPTIONS: s_objec FOR tadir-object.
SELECT-OPTIONS: s_objnm FOR tadir-obj_name DEFAULT 'Z*' OPTION CP.
PARAMETERS: p_text TYPE string.
START-OF-SELECTION.
SELECT
tadir~pgmid,
tadir~object,
tadir~obj_name,
trdir~subc,
tadir~devclass
FROM tadir
LEFT OUTER JOIN trdir ON tadir~object = 'PROG' AND tadir~obj_name = trdir~name
INTO TABLE @DATA(lt_objects)
WHERE tadir~devclass IN @s_devc
AND tadir~object IN @s_objec
AND tadir~obj_name IN @s_objnm
AND ( tadir~object = 'PROG' OR tadir~object = 'FUGR' OR tadir~object = 'CLAS' ).
LOOP AT lt_objects ASSIGNING FIELD-SYMBOL(<object>).
IF <object>-object = 'PROG' AND ( <object>-subc = '1' OR <object>-subc = 'M' ).
DATA: lt_tpool TYPE STANDARD TABLE OF textpool WITH DEFAULT KEY.
CALL FUNCTION 'RS_TEXTPOOL_READ'
EXPORTING
objectname = <object>-obj_name
action = 'READ'
* AUTHORITY_CHECK = ' '
language = sy-langu
TABLES
tpool = lt_tpool
EXCEPTIONS
object_not_found = 1
permission_failure = 2
invalid_program_type = 3
error_occured = 4
action_cancelled = 5
OTHERS = 6.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT lt_tpool ASSIGNING FIELD-SYMBOL(<tpool>).
IF <tpool>-id = 'I' AND <tpool>-entry CP p_text.
WRITE: <object>-obj_name, <tpool>-key, <tpool>-entry.
ENDIF.
ENDLOOP.
ELSEIF <object>-object = 'FUGR'.
DATA: lv_fugr TYPE rs38m-programm.
lv_fugr = 'SAPL' && <object>-obj_name.
CALL FUNCTION 'RS_TEXTPOOL_READ'
EXPORTING
objectname = lv_fugr
action = 'READ'
* AUTHORITY_CHECK = ' '
language = sy-langu
TABLES
tpool = lt_tpool
EXCEPTIONS
object_not_found = 1
permission_failure = 2
invalid_program_type = 3
error_occured = 4
action_cancelled = 5
OTHERS = 6.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT lt_tpool ASSIGNING <tpool>.
IF <tpool>-id = 'I' AND <tpool>-entry CP p_text.
WRITE: <object>-obj_name, <tpool>-key, <tpool>-entry.
ENDIF.
ENDLOOP.
ELSEIF <object>-object = 'CLAS'.
DATA: lv_clas TYPE rs38m-programm.
lv_clas = <object>-obj_name.
DATA(lv_eq_count) = 30 - strlen( lv_clas ).
DO lv_eq_count TIMES.
lv_clas = lv_clas && '='.
ENDDO.
lv_clas = lv_clas && 'CP'.
CALL FUNCTION 'RS_TEXTPOOL_READ'
EXPORTING
objectname = lv_clas
action = 'READ'
* AUTHORITY_CHECK = ' '
language = sy-langu
TABLES
tpool = lt_tpool
EXCEPTIONS
object_not_found = 1
permission_failure = 2
invalid_program_type = 3
error_occured = 4
action_cancelled = 5
OTHERS = 6.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT lt_tpool ASSIGNING <tpool>.
IF <tpool>-id = 'I' AND <tpool>-entry CP p_text.
WRITE: <object>-obj_name, <tpool>-key, <tpool>-entry.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
END-OF-SELECTION.
WRITE: / 'Search completed:', p_text.