To get the callstack in ABAP, simply call the following line:
DATA(lt_callstack) = cl_abap_get_call_stack=>format_call_stack_with_struct( cl_abap_get_call_stack=>get_call_stack( ) ).
Then you can access the callstack the same way you see it in the debugger, e.g. the name of the program will be in lt_callstack-progname.