‎2005 Mar 08 5:41 PM
hi all,
My requirement is to search a string in a function module source code. Is there any statment to read the source of the function module into a internal table . i kown one statement which read the report source code (read report 'z_..' into itab, similarly is there any stmt. / standard SAP program which do the same.
thanks
vijay.
‎2005 Mar 08 5:46 PM
‎2005 Mar 08 6:01 PM
You could write your own function module to retrieve the source code of the program and all of the includes of a program. Just convert this sample program to a function module. You will need to do some coding to retrieve the includes of the program.
report zrich_0001
no standard page heading
line-size 300.
parameters: p_prog(60) type c.
data: begin of s occurs 0,
txt(300) type c,
end of s.
read report p_prog into s.
loop at s.
write:/ s-txt.
endloop.
Regards,
Rich Heilman
‎2005 Mar 08 5:59 PM
Hi mani,
Every function module is a program by itself. So if a function module belongs to function group XYZ, then the main program name will be SAPLXYZ and the function module's source code program will be in the form of LXYZUnnn(where nnn is a sequential number). You can get this information from the attributes tab of the function module in SE37.
You can use 'READ REPORT' to read the code of the function module. But if you are looking for all the subroutines that are written in includes of the main program, then you need to code for reading it. There is not standard way to get it.
Here is a logical flow.
1. Get the main program of the function module and the include name for the function module.
2. Read report 'main program'. on each line search for the pattern 'LXYZU' and read that include name. For each include you can do a 'read report'. That way you will get the source code of the complete function group, not just the function module. But if it is just the function module code, you are interested in, then simply do a 'read report <function module include name here>'.
Regards,
Srinivas
Message was edited by: Srinivas Adavi
Alternatively, you can also use the function module 'SCWB_GET_ABAP_CODE_OF_OBJECT'.
‎2005 Jun 24 11:57 AM
hi srinivas can u give me the right syntax for reading a function module code in internal table.
u can mail me on azeeash79@yahoo.com
regards,
azee
‎2005 Jun 25 7:35 AM
Here we go ...
DATA : GV_PROG_NAME TYPE TRDIR-name.
SELECT SINGLE *
FROM TFDIR
WHERE funcname = P_PROGF.
IF SY-subrc EQ 0.
CONCATENATE TFDIR-pname 'U' tfdir-include INTO GV_PROG_NAME.
GV_PROG_NAME = gv_prog_name+3(30).
ELSE.
MESSAGE e001(AQ) WITH
'Function module does not exit'.
ENDIF.
* read the report code lines in an internal table
READ REPORT GV_PROG_NAME INTO GT_REP_TABLE.
IF SY-subrc < > 0.
MESSAGE e001(AQ) WITH
'Code is blank'.
EXIT.
ENDIF.
This should be enough or else check this link:
http://www.geocities.com/rmtiwari/Resources/Utilities/WebViewer.html
Thanks,
Ram
Message was edited by: Ram Manohar Tiwari
‎2005 Mar 09 7:22 AM
‎2005 Jun 25 2:08 PM
Hi ,
You can use the standard SAP Program RKCTSEAR for searching strings contained in the source code of any program.
Regards,
K Vijayasekar