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

reading sourcecode of function modules

Former Member
0 Likes
3,001

Hello experts,

I want to search a string in the sourcecode of function modules.

i had already programmed a version for abap programms, but the function READ REPORTS does not accept function modules.

thx for help

D. S.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,395

Hi

The function module is write in an include so u need to transfer the name of the include instead of the name of function.

U can see the name of the include in the property tab in trx SE37

Max

Edited by: max bianchi on Dec 4, 2008 10:16 AM

14 REPLIES 14
Read only

Former Member
0 Likes
2,396

Hi

The function module is write in an include so u need to transfer the name of the include instead of the name of function.

U can see the name of the include in the property tab in trx SE37

Max

Edited by: max bianchi on Dec 4, 2008 10:16 AM

Read only

h_senden2
Active Contributor
0 Likes
2,395

The source code of function modules (in functiongroup ZTST) can be found in LZTSTU01 etc. Includes will be LZTST

regards,

Hans

Read only

Former Member
0 Likes
2,395

Hi,

you need to put in the name of the include

and not the FM

-Raj

Read only

Former Member
0 Likes
2,395

Hi,

As you have to search a string in a FM then it means that you have to read a function module so to do this go to transaction SE37 and then you write the name of a required FM and press the display tab .

then you can easily go through the FM and can search for the required string.

Regards,

Anand

Read only

Former Member
0 Likes
2,395

Try to use read textpools ,i think this includes function modules.

Read only

Former Member
0 Likes
2,395

okay with include it works,

but I want to scan all* function modules

(* frist I scan the first 1000 only).

can i read the include of some table? The column "include" of the table TFDIR has only numbers but no names.

and how can I get back the name of the function module if I have the include?

Read only

i048168
Product and Topic Expert
Product and Topic Expert
0 Likes
2,395

Hi,

Use the following FM to get the include name of the function module.

CALL FUNCTION 'FUNCTION_EXISTS'

EXPORTING

funcname = lv_functionname

IMPORTING

include = lv_include

namespace = lv_namespace

str_area = lv_str_area

EXCEPTIONS

function_not_exist = 1.

Now you can use lv_include as the program name in read report.

Regards,

Vadivelan B

Read only

Former Member
0 Likes
2,395

Thanks, I think that schould work,

but now I understand one of the answears above, with adding an "L" before the name and adding the include number at the end. I think this solution is a little bit faster (´cause there are a lot of function modules to scan)

Read only

Former Member
0 Likes
2,395

Hi

Yes you're right, u need a code like this:

tables: tfdir.

data: v_include   type trdir-NAME,
      v_funcgroup(30) type C.

parameters: p_func type tfdir-FUNCNAME.


select single * from tfdir where FUNCNAME = p_func.

v_funcgroup = TFDIR-PNAME+4.

concatenate 'L' v_funcgroup 'U' tfdir-INCLUDE into v_include.
condense v_include.

write: v_funcgroup, v_include.

But I'm not sure this solution can be faster than call FUNCTION_EXISTS, because they do the same thing.

Max

Read only

Former Member
0 Likes
2,395

Well the results are teh same but the function module FUNCTION_EXISTS has 130 lines of code (minus lines of comments). And at least with direct sql-statements you save 1 function call. It sound not much but SAP has more than 683 function modules.

Read only

Former Member
0 Likes
2,395

Okay my programm works.

But im still using "....up to 1000 rows" in my select-statement.

can I say something like: ".....where rownr between 1000 and 2000"? known from Oracle

than I can go trough the database step by step

Read only

Former Member
0 Likes
2,395

Hi

I believe it can't do it, it can only indicate the max number of hits to be extracted.

I think every time a "SELECT" is open the cursor starts from the beginning.

Try to check the command OPEN CURSOR.

Max

Read only

Former Member
0 Likes
2,395

But the good news is, that the number of function mudules is 10% of the the number of abap-reports, so I can go trough in 1 step. (takes less then 10 minutes)

Read only

Former Member
0 Likes
2,395

TYPES: BEGIN OF progstruc,

name TYPE string,

grp TYPE string,

inclu TYPE string,

END OF progstruc.

DATA tmp0 TYPE progstruc.

DATA prog TYPE c LENGTH 60.

DATA itab TYPE TABLE OF string.

DATA iline TYPE string.

DATA tmp1 TYPE i.

DATA tmp2 TYPE i.

DATA prognames TYPE TABLE OF progstruc.

parameter strg TYPE string.

select FUNCNAME PNAME INCLUDE

from TFDIR

into table prognames.

loop at prognames into tmp0.

tmp0-grp = tmp0-grp+3.

CONCATENATE '' tmp0-grp 'U' tmp0-inclu ''

into prog.

READ REPORT prog INTO itab.

tmp1 = 0.

tmp2 = sy-subrc.

IF tmp2 = 0.

LOOP AT itab into iline.

SEARCH iline FOR strg.

IF sy-subrc = 0.

tmp1 = 1.

ENDIF.

ENDLOOP.

IF tmp1 = 1.

WRITE : / tmp0-name.

ENDIF.

ENDIF.

endloop.