Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
johna69
Product and Topic Expert
Product and Topic Expert
0 Kudos

The following will show a simple way for you to use Argo to search for text in ABAP reports and classes. The search looks in TRDIR to find matching reports and then searches the text for the given search string.


Service Definition




The first step is to create a function module to perform the actual search.


Remote enable the function module and create the following parameters:

Input



The two import parameters needed are shown in the image below. IV_STRING contains the text to be searched for, IV_REP contains the filter information for the reports to be searched. Passing Z would restrict the search to only TRDIR entries starting with Z. An important note here is that probably want to filter your reports all the time. If you don't then every report is searched and it is likely that you will get timeouts due to the large volume of entries.

Output



The output is a table of the TRDIR entry and the line of text from the report. This is achieved by creating a structure that includes TRDIR and one more entry LV_LINE of predefined type STRING. A table type is then created for this structure.



Function Module Source Code




FUNCTION ZJA_GREP2.

*"----


""Local Interface:

*"  IMPORTING

*"     VALUE(IV_STRING) TYPE  STRING

*"     VALUE(IV_REP) TYPE  STRING

*"  EXPORTING

*"     VALUE(ET_RESULTS) TYPE  ZJTT_GREP

*"----


  DATA: lt_trdir TYPE STANDARD TABLE OF trdir,

        ls_trdir TYPE trdir,

        lt_text TYPE STANDARD TABLE OF string,

        lv_text TYPE string,

        lv_repname TYPE string,

        lv_line TYPE STRING,

        ls_results TYPE zjs_grep.

  FIELD-SYMBOLS  TYPE string.

" Simple check so that not everything is returned.

  IF iv_string IS INITIAL AND iv_rep IS INITIAL.

    RETURN.

  ENDIF.

  • Check the report string

  IF NOT iv_rep CS '%'.

    CONCATENATE iv_rep '%' INTO lv_repname.

  ELSE.

    lv_repname = iv_rep.

  ENDIF.

  TRANSLATE lv_repname TO UPPER CASE.

  lv_text = iv_string.

  • Get the report names.

  SELECT * FROM trdir INTO TABLE lt_trdir WHERE name LIKE lv_repname.

  IF sy-subrc EQ 0.

    TRANSLATE lv_repname TO UPPER CASE.

    lv_text = iv_string.

  • Get the report names.

    SELECT * FROM trdir INTO TABLE lt_trdir WHERE name LIKE lv_repname .

    IF sy-subrc EQ 0.

      LOOP AT lt_trdir INTO ls_trdir.

  • Now read the report and search the text.

        READ REPORT ls_trdir-name INTO lt_text.

        LOOP AT lt_text ASSIGNING

Create new Argo object with the Argo Web Service Wizard shows how to create a connector for a web service in Argo. For this example I used the name and lv_line parameters from the results list. The name identifies the report, lv_line contains the text from the report.


Results




Now that you are fully configured you should be able to run your search. I gave my connector the name "grep". If I want to execute a search using my connector I would use "grep if_model" to search for the text if_model in the reports.

Web Page Results

Widget Results


Next Steps




This was only a demo on how to get started, there is lots of room for improvement. For starters the search is very simple, pass text and a report filter. It does not cover wild card searches etc.


Another improvement could be a link to allow the report to be displayed by clicking on the results.

If there is sufficient interest I can take this example to the next step.

4 Comments