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

Read Source Codes

Former Member
0 Likes
1,645

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!

1 ACCEPTED SOLUTION
Read only

praveen_hannu
Contributor
0 Likes
1,150

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

3 REPLIES 3
Read only

praveen_hannu
Contributor
0 Likes
1,151

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

Read only

0 Likes
1,150

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?

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,150

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]