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

How to get Function Module Name at runtime?

c_c2
Participant
0 Likes
2,548

Hi All,

There is any way to get the Function Module Name inside that function module?

In debug we can see 2 fields on top showing PROGRAM_NAME and PROGRAM_TYPE. On case of function it shows:

PROGRAM_TYPE: Fucntion

PROGRAM_NAME: Y_XPTO_ABCD

I need at leadt the program name, since the sy-repid only returns the function group name.

Best regards.

2 REPLIES 2
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,211

Call FM [SYSTEM_CALLSTACK|http://www.sdn.sap.com/irj/scn/advancedsearch?query=system_callstack].

  DATA: lt_callstack TYPE abap_callstack,
        ls_callstack TYPE abap_callstack_line,
        lv_fname TYPE rs38l_fnam.

  CALL FUNCTION 'SYSTEM_CALLSTACK'
    EXPORTING
      max_level = 0
    IMPORTING
      callstack = lt_callstack.

  CLEAR lv_fname.
  LOOP AT lt_callstack INTO ls_callstack. " or read INDEX 1
    CHECK ls_callstack-blocktype EQ 'FUNCTION'.
    lv_fname = ls_callstack-blockname.
    EXIT.
  ENDLOOP.

  IF lv_fname IS INITIAL.
    WRITE: / 'Outside of any Function Module'.
  ELSE.
    WRITE: / 'Inside', lv_fname, 'Function Module'.
  ENDIF.

Regards,

Raymond

Read only

davis_raja
Active Participant
0 Likes
1,211

You can also EXPORT the program name to a MEMEORY ID and you can IMPORT it in your FM