‎2010 Mar 30 4:20 AM
hi,
as we know, to read a program''s source, we use the statement READ REPORT .....
now my question is, how about on function modules?
how do i read a function module's source code?
thanks!
‎2010 Mar 30 4:40 AM
Hi
Every function module has attached to a include in the function group, try to read that include source code, if you need to get the source of a function module. Its just a idea.
Thanks
Praveen
‎2010 Mar 30 4:40 AM
Hi
Every function module has attached to a include in the function group, try to read that include source code, if you need to get the source of a function module. Its just a idea.
Thanks
Praveen
‎2010 Mar 30 4:46 AM
hi praveen,
nice idea, would you know if all function module include programs start with L all the time? even customized FMs?
and will no other types of programs uses L as the beginning letter?
‎2010 Mar 30 4:59 AM
Hello,
Try this code:
DATA: V_PNAME TYPE PNAME,
V_INCL TYPE INCLUDENR,
V_REPID TYPE SY-REPID,
ITAB TYPE TABLE OF STRING,
WA TYPE STRING.
PARAMETERS: P_FNAME LIKE TFDIR-FUNCNAME.
SELECT SINGLE PNAME INCLUDE
INTO (V_PNAME,V_INCL)
FROM TFDIR
WHERE FUNCNAME = P_FNAME.
IF SY-SUBRC = 0.
CONCATENATE V_PNAME 'U' V_INCL INTO V_REPID.
V_REPID = V_REPID+3.
ENDIF.
TRY.
READ REPORT V_REPID INTO ITAB.
CATCH CX_SY_READ_SRC_LINE_TOO_LONG .
ENDTRY.
IF SY-SUBRC = 0.
WRITE: 'Report is read. Hurray !!!'.
LOOP AT ITAB INTO WA.
WRITE / WA.
ENDLOOP.
ENDIF.Why did i concatenate 'U' to the variable V_REPID & remove the first 3 characters (which were 'SAP') before using READ REPORT ?
1. For using READ REPORT on include programs SAP says:
To use the READ REPORT statement for programs that are organized in framework programs and Include programs when created in the ABAP Workbench, you need to know exactly how the programs are structured as well as their names.
The names of the framework programs for class pools and function group do not match the names of the global class and function group (see CLASS-POOL and FUNCTION-POOL statements).
2. On how the include programs are arranged in a function group read this : [http://help.sap.com/abapdocu_70/en/ABAPFUNCTION-POOL.htm|http://help.sap.com/abapdocu_70/en/ABAPFUNCTION-POOL.htm]