Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Search for text in function modules

Former Member
0 Likes
2,742

Good day everyone...

I am wondering if anyone knows of a report similar to RPR_ABAP_SOURCE_SCAN that can be used to search for a string of text in function modules. RPR_ABAP_SOURCE_SCAN is great for searching through report programs for text, but I need to be able to expand this. Maybe there is a better way to search both? I have used RPR_ABAP_SOURCE_SCAN for so long that I am unaware of anything to do what I need now with function modules.

Any help would be greatly appreciated.

Thank you!

5 REPLIES 5
Read only

ssimsekler
Product and Topic Expert
Product and Topic Expert
0 Likes
1,373

Hi Geoff

Every function module is addressed by an include of the function group which it belongs. I guess it can be retrieved from the table <b>"TFDIR"</b>. So, knowing this include name, you can use the report "RPR_ABAP_SOURCE_SCAN" passing the include name as the parameter.

Hope this helps...

*--Serdar

Read only

nablan_umar
Product and Topic Expert
Product and Topic Expert
0 Likes
1,373

Hi Geoff,

Function module belongs to a function group. Function group starts with SAPLxxx, where xxx is the function group name. When you run RPR_ABAP_SOURCE_SCAN, you can enter the full program name of the function group SAPLxxx and set the program type as 'F'.

Read only

Former Member
0 Likes
1,373

You can do much more than that.You can read the source code and pass it to SCAN statement which will break the code in tokens and return values in internal table and then you can do search whichever way you want.

Read only

Former Member
0 Likes
1,373

Thanks a lot for the help...Got the scan program to work with the SAPLZxxx function groups and program type F as specified.

Read only

Former Member
0 Likes
1,373

Here a programm I used some years ago to search for strings in abap source code.

It works in 2 steps:

1) create list of sources from TRDIR into file(s)

2) walk thru list of sources and scan for strings

Step 2 may run in parallel on lists of disjunct source name ranges

No guarantee that it still works, no support.

Have lots of fun with it.

Guenter

&----


*& Report ZASRCH01 *

&----


*& search for occurrance of strings in ABAP sources *

*& *

*& parameters: *

*& str_1 ... str_n: strings to be searched, AND combined *

*& repname: for TRDIR select like *

*& infile: list of reports to be scanned, TRDIR is default *

*& outfile: list of reports where strings are contained *

&----


REPORT ZASRCH01.

parameters: str_1(40), str_2(40), str_3(40), str_4(40).

parameters: repname(40).

parameters: infile(40) default '&TRDIR&'.

parameters: outfile(40) default 'ZASRCH01_RESULT_1'.

parameters: progfile(40) default 'ZASRCH01_PROGRESS_1'.

tables: trdir.

data: begin of my_trdir occurs 0, name like trdir-name, end of my_trdir.

TYPES:BEGIN OF T_TYPE, LINE(80), END OF T_TYPE.

DATA: PROGRAM LIKE SY-REPID VALUE 'PROGNAME',

T TYPE STANDARD TABLE OF T_TYPE WITH

NON-UNIQUE DEFAULT KEY INITIAL SIZE 500.

data: str_num type i, str_found type i, loopcount type i.

*--- get report names ... ---

if infile = '&TRDIR&'.

*--- ... from TRDIR ---

if repname <> space.

select * from trdir where name like repname.

my_trdir = trdir. append my_trdir.

endselect.

else.

select * from trdir.

my_trdir = trdir. append my_trdir.

endselect.

endif.

else.

  • open dataset infile for input in text mode encoding UTF-8. "???

open dataset infile for input in text mode.

*--- from input file ---

do.

read dataset infile into my_trdir.

if sy-subrc <> 0. exit. endif.

append my_trdir.

enddo.

endif.

  • open dataset outfile for output in text mode encoding UTF-8. "???

  • open dataset progfile for output in text mode encoding UTF-8. "???

open dataset outfile for output in text mode.

open dataset progfile for output in text mode.

      • loop over selected reports, scan for strings

loop at my_trdir.

loopcount = loopcount + 1.

if loopcount > 1000.

loopcount = 0. commit work.

endif.

transfer my_trdir-name to progfile.

refresh T.

READ REPORT my_trdir-name INTO T.

str_num = 0. str_found = 0.

perform search_in_record using str_1.

perform search_in_record using str_2.

perform search_in_record using str_3.

perform search_in_record using str_4.

if str_num > 0 and str_found >= str_num.

write: / my_trdir-name. "??? eliminate ???

transfer my_trdir-name to outfile.

endif.

endloop.

----


  • form for scanning a single source *

----


form search_in_record using str.

if str <> space.

str_num = str_num + 1.

search t for str.

if sy-subrc = 0.

str_found = str_found + 1.

endif.

endif.

endform.