Application Development 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: 

Function module name..sy-repid equivalent

former_member186741
Active Contributor
0 Kudos

does anybody know how to identify within a function module what it's name is? i.e. is there a similar variable to sy-repid to identify what the current function module is?

I know sy-repid will identify the main program of the function group, I want the name of the function module.

I am creating a mechanism to log the parameters sent to calls of function modules. I have created a custom table to hold the data and one of the key fields is the name of the function module. Currently I hard-code the name when I enable this logging within a function module but I wondered if there is a variable somewhere which holds the name.

This mechanism will be used by many function modules and I can't change the interfaces, say to use a new parameter. I want this function to be able to be plugged into any fm I choose.

The prototype mechanism needs a few lines of code inserted in each fm that's going to be log-enabled. It uses a macro which takes the function module name as a parameter, works out what the parameters are called and what their values are and puts them in a custom table. Then there is an associated report which browses this table and formats the parameters appropriately.

Update........

It seems this can't be done. Rob is right that the name is knowable but I think it's hidden away in the deep magic of the kernal. Any more ideas before I close the thread?

Further Update:

thanks Stefan - this looks exactly what I need. I will check it out thoroughly before awarding you full points!

Finally:

SYSTEM_CALLSTACK works perfectly for my purposes. I no longer have to hard-code the name of the function module I am trying to log.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

you can try FM "SYSTEM_CALLSTACK". Take in the resulting table the first entry with ProgName = SY-REPID and eventType = FUNC. Field Eventname contains FM-Name.

I tested it in some cases and it seems to work. However, I found no official documentation about it!!!

Best regards,

Stefan

5 REPLIES 5

Former Member
0 Kudos

What exactly is your requirement ?

0 Kudos

Hi Neil,

Is this a custom function module? If yes, add a parameter to pass the name of the function module..

I thought so...you couldn't have missed something obvious.. OK how do you intend to plug-in your mechanism in different function modules?

Regards,

Suresh Datti

Message was edited by: Suresh Datti

Former Member
0 Kudos

Well, the ABAP debugger knows the name of the FM that you're in, so it must be knowable. Maybe a kernel call of some kind??

Rob

0 Kudos

you can try something like below.

before call of the FM in your program

do a set parameter

set parameter id 'LIB' field <FMNAME> .

and within your FM

data: fmname(30) .

get parameter id 'LIB' field fmname .

Regards

Raja

Former Member
0 Kudos

Hello,

you can try FM "SYSTEM_CALLSTACK". Take in the resulting table the first entry with ProgName = SY-REPID and eventType = FUNC. Field Eventname contains FM-Name.

I tested it in some cases and it seems to work. However, I found no official documentation about it!!!

Best regards,

Stefan