ABAP Program to search specific words(string) in SAP Programs


This utility searches ABAP program source code listings for a particular string within the code or text elements of the program. 
This can be use:
1. To find out which program has generated a particular BDC session(Groupid in SM35), especially when the session name is maintainned in the text elements.
2. To serach administrative information maintened in the control section of program source code, like who created etc.
3. To search a particular piece which might be reusable and not easily comng on top of developers mind as to which program he or she coded it in.
4. Can be used to find out hard codings, especially offsets in date related hard coding which has to be replaced with more generic logic.
5. Can be used as a extended where used list functionality

The current code has a selection screen, using which, a range of programs can be selected based on the Program Type (1, M, I, etc.), development class. It also provides option to serach for a given string in text elements of the program. Currently the code allows a search for custom pprograms starting with ‘Z’. A source code change can be made to serach in other namespaces.

Selection Screen

It output displays the program name, number of programs the string was present in. On the basic list, a click on a program name takes the user to SE38 intial screen and the progra name is filled up automtically. On pressing back from SE38 brings the user back to the basic list.


report ytest_round_temp1  line-size 255 no standard
                                            page heading.

tables : tadir, trdir.

*PARAMETERS : p_string(40) OBLIGATORY lower case,
select-options : s_string for trdir-name obligatory lower case.
*             p_pat(1) ,
parameters : p_pgmid  like tadir-pgmid  default ‘R3TR’,
             p_object like tadir-object default ‘PROG’,
             p_subc   like trdir-subc   default ‘1’,
             cb_text as checkbox.
data : begin of it_prog occurs 0,
              name like trdir-name,
end of it_prog,
       begin of it_source occurs 0,
end of it_source.
data : wf_flag(1) type n,
       wf_temp like trdir-name,
       tab like textpool occurs 50 with header line.
data : count type i.

*CONCATENATE ‘*’ p_string ‘*’ INTO p_string.

loop at s_string.
  concatenate ‘*’ s_string-low ‘*’ into s_string-low.
  condense s_string-low no-gaps.
  modify s_string index sy-tabix.

select trdir~name into corresponding fields of table it_prog
             from tadir inner join trdir on trdir~name =  tadir~obj_name
              where tadir~pgmid  = p_pgmid
                and tadir~object = p_object
                and trdir~subc   = p_subc
                and trdir~name   like ‘Z%’
                and tadir~obj_name like ‘Z%’.

sort it_prog.

loop at it_prog.
  if cb_text ne ‘X’.
    read report it_prog-name into it_source.
    read textpool it_prog-name into it_source language sy-langu.
*  if sy-subrc = 0.
    wf_flag = 0.
    loop at s_string.
      loop at it_source where line cp s_string-low.

        if wf_flag = 0.
          count = count + 1.
          write : /1(8) count, 9(3) ‘ . ‘, 12(132) it_prog-name color 7
            hotspot on.
          wf_temp = it_prog-name.
          hide wf_temp.

          wf_flag = 1.

        format color  2.
        write : /1(1) sy-vline, 2(132) it_source-line, 134(1) sy-vline.
        format color off.

      if sy-subrc = 0.
        write : /2(1) ‘*’, 3(131) space.
    refresh it_source. clear it_source.
*  endif.


at line-selection.
  case sy-lsind.
    when ‘1’.
      set parameter id ‘RID’ field wf_temp.
      call transaction ‘SE38’ and skip first screen. .


*Source = Amit Tyagi


Please enter your comment!
Please enter your name here