Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Get information for classes from call stack in abap (like java reflection)

Hi,

is there any possibilty to get following information:

I want to program a logging tool. You can create a logging object and use some methods like

xxxxx->add_msg(msg) to put logging information to the logging object.

but i also want to find out, from which class/object/runtime environment this msg comes.

example:

class CL_ABC uses the logging tool and does following call:

....

lo_logger = CL_logger->get_logger().

lo_logger->add_msg( 'test the code' ).

....

now the method ->add_msg() in logger object is called. inside this method, i want to have the information, from which class/object the ->add_msg() method is called. after the call, the logging object must have this information like:

CALL_CLASS: CL_ABC

CALL_LINE: 83

MSG: test the code

any ideas?

replied

You can use the SYSTEM_CALLSTACK function module.

Read this thread, Uwe has given details on both getting the calling class and method: How to determine current method / interface method that is running?

Most probably this solves your needs.

Regards

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question