REPORT z_so10_search.
TABLES: stxh.
*-----------------------------------------------------------------------
* Types& Data Definition
*-----------------------------------------------------------------------
TYPES: BEGIN OF ty_out,
tdobject TYPE stxl-tdobject,
tdname TYPE stxl-tdname,
tdid TYPE stxl-tdid,
tdspras TYPE stxl-tdspras,
tdformat TYPE tdformat,
flag TYPE flag,
tdline TYPE tdline,
END OF ty_out.
DATA: gt_out TYPE TABLE OF ty_out,
gs_out TYPE ty_out.
TYPES: BEGIN OF ty_stxh,
tdobject TYPE stxl-tdobject,
tdname LIKE stxh-tdname,
tdspras LIKE stxh-tdspras,
END OF ty_stxh.
DATA: gt_stxh TYPE TABLE OF ty_stxh,
gs_stxh TYPE ty_stxh,
gt_lines LIKE TABLE OF tline,
gs_lines LIKE LINE OF gt_lines.
*-----------------------------------------------------------------------
* Selection Parameters
*-----------------------------------------------------------------------
SELECTION-SCREEN: BEGIN OF BLOCK a2 WITH FRAME TITLE text-002.
PARAMETERS p_search(80) OBLIGATORY.
PARAMETERS: P_match AS CHECKBOX. "display only specific line
SELECTION-SCREEN: END OF BLOCK a2.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN: BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_tdname FOR stxh-tdname.
PARAMETERS p_obj TYPE stxh-tdobject OBLIGATORY DEFAULT 'TEXT'.
PARAMETERS p_id TYPE stxh-tdid DEFAULT 'ST'.
PARAMETERS p_langu LIKE stxh-tdspras DEFAULT 'EN'.
SELECTION-SCREEN: END OF BLOCK a1.
*-----------------------------------------------------------------------
* START-OF-SELECTION
*-----------------------------------------------------------------------
START-OF-SELECTION.
PERFORM get_data.
*-----------------------------------------------------------------------
* FORM GET_DATA
*-----------------------------------------------------------------------
FORM get_data.
DATA: l_tab_tadir TYPE TABLE OF tadir,
l_str_tadir TYPE tadir,
l_tabix_str(10) TYPE c,
l_percentage TYPE p,
l_cnt TYPE i,
l_text TYPE itex132,
l_cnt_str(10) TYPE c.
REFRESH gt_stxh.
SELECT tdobject tdname tdspras
FROM stxh
INTO TABLE gt_stxh
WHERE tdname IN s_tdname
AND tdobject = p_obj
AND tdid = p_id
AND tdspras = p_langu.
* Write count of programs into list
DESCRIBE TABLE gt_stxh LINES l_cnt.
IF l_cnt = 0.
EXIT.
ENDIF.
l_cnt_str = l_cnt.
CONDENSE l_cnt_str.
REFRESH: gt_out.
LOOP AT gt_stxh INTO gs_stxh.
l_tabix_str = sy-tabix.
CONDENSE l_tabix_str.
IF l_cnt IS NOT INITIAL.
* Display progress indicator
l_percentage = 100 * ( sy-tabix / l_cnt ).
CONCATENATE '(' 'Processing'(009) l_tabix_str 'of'(010) l_cnt_str ')'
'Searching Text object'(008) gs_stxh-tdname
INTO l_text SEPARATED BY space.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = l_percentage
text = l_text.
ENDIF.
REFRESH gt_lines.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = p_id
language = gs_stxh-tdspras
name = gs_stxh-tdname
object = p_obj
TABLES
lines = gt_lines
EXCEPTIONS
id = 0
language = 0
name = 0
not_found = 0
object = 0
reference_check = 0
wrong_access_to_archive = 0
OTHERS = 0.
FIND ALL OCCURRENCES OF REGEX p_search IN TABLE gt_lines
* RESPECTING CASE
RESULTS DATA(results).
SEARCH gt_lines FOR p_search.
IF sy-subrc EQ 0.
CONDENSE gs_stxh-tdname.
CLEAR gs_out.
MOVE-CORRESPONDING gs_stxh TO gs_out.
LOOP AT gt_lines INTO gs_lines.
gs_out-tdformat = gs_lines-tdformat.
gs_out-tdline = gs_lines-tdline.
SEARCH gs_lines FOR p_search.
IF sy-subrc EQ 0.
gs_out-flag = 'X'.
ELSE.
CLEAR gs_out-flag.
if P_match = 'X'.
CONTINUE.
endif.
ENDIF.
APPEND gs_out TO gt_out.
ENDLOOP.
ENDIF.
ENDLOOP.
IF gt_out[] IS NOT INITIAL.
cl_demo_output=>display_data( gt_out ).
ELSE.
WRITE: / 'String not found!'.
ENDIF.
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |