Skip to Content

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.

image

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.

image

image

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

image

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

image

Widget Results

image

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.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Anonymous
    Hi John,

    You make it so simple. As you talk about reports, wouldn’t it to be cool to just enter the name of the report (may be with a variant) and get the results back in Argo. Then I can get my report offine using the mail client or use web ui to get the report online without ever going to my system.

    What do you think?

    Regards,
    Bala.

    (0) 
  2. tamilarasan kandasamy
    hi
    i read ur weblog its interesting.
    i am working with respect to ur blog but the coding which u written shows an error.
    the error is the structure u defined is not an internal table i.e(in append statement).
    plz reply as soon as possible.

    regards,
    tamil.

    (0) 
    1. John Astill Post author
      the export parameters should be defined as a table type not a structure. zjtt_grep is a table type of structure ZJS_GREP.

      John

      (0) 

Leave a Reply