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

Get class/variable from ABAP Callstack.

Former Member
10,514

Hi,

I need some information in one of my methods.

The info residing in higher level method in the ABAP Callstack.

My callstack looks like this

Event Type___Event_______________________________Program

METHOD___IF_RSPLS_CR_METHODS~DERIVE_____ZFIB0001_IP_CHAR_REL==========CP <- I'm here.

METHOD___IF_RSPLS_CR_MAPPER~DERIVEM_____CL_RSPLS_CR_MAPPER============CP

METHOD___IF_RSPLS_CR_CONTROLLER~DERIVE__CL_RSPLS_CR_CONTROLLER========CP

METHOD___CR_DERIVE_________________________CL_RSPLS_DELTA_BUFFER_B=======CP

METHOD___WRITE______________________________CL_RSPLS_DELTA_BUFFER_B=======CP

METHOD___WRITE______________________________CL_RSPLS_DELTA_BUFFER_AM======CP

METHOD___WRITE_EXT__________________________CL_RSPLS_DELTA_BUFFER=========CP

METHOD___STORE_DELTA_IN_BUFFER____________CL_RSPLFR_CONTROLLER==========CP

METHOD___EXECUTE_SERVICE___________________CL_RSPLFR_CONTROLLER==========CP

METHOD___EXECUTE____________________________CL_RSPLFR_WEB_START_SERVICE===CP

FUNCTION_BICS_CONS_EXECUTE_PLANNING_FUN__SAPLRSBOLAP_BICS_CONSUMER

FORM_____BICS_CONS_EXECUTE_PLANNING_FUN__SAPLRSBOLAP_BICS_CONSUMER

FORM_____REMOTE_FUNCTION_CALL_____________SAPMSSY1

MODULE___%_RFC_START_______________________SAPMSSY1

I need to access line 4 from the bottom (function in SAPLRSBOLAP_BICS_CONSUMER).

From here i need to access

L_R_DATA_PROVIDER which is a class type CL_RSPLFR_WEB_START_SERVICE.

I have tried to use the method in , but so far it has been unsuccesful.

Is it possible to gain access to a class higher in the hierarchy ?

Br Rasmus

14 REPLIES 14
Read only

naimesh_patel
Active Contributor
0 Likes
4,560

To get an access of the object, you can try this way:


  DATA: ld_class  TYPE string,
        ld_method TYPE string.
  DATA: lo_obj    TYPE REF TO object.
  FIELD-SYMBOLS:
   <lo_provider>   TYPE ANY.

  ld_class = '(SAPLRSBOLAP_BICS_CONSUMER)L_R_DATA_PROVIDER'.
  ASSIGN (ld_class) TO <lo_provider>.

Now, if you want to execute the method, you can try this way:


  lo_obj ?= <lo_provider>.
  ld_method = 'LINE_GET'.
  CALL METHOD lo_obj->(ld_method)
    ....

To get an access of the public attributes:


 ld_class = '(SAPLRSBOLAP_BICS_CONSUMER)L_R_DATA_PROVIDER->attr'.  "put actual attribute name
  ASSIGN (ld_class) TO <lo_attr>.

Regards,

Naimesh Patel

Read only

0 Likes
4,560

Hi Naimesh,

Thanks for your post.

I have tried you suggestion, but the <lo_provider> does not get assigned.


    lookup_string = '(SAPLRSBOLAP_BICS_CONSUMER)L_R_DATA_PROVIDER'.
    ASSIGN (lookup_string) to <lookup>.
    IF <lookup> is ASSIGNED.
    lo_obj ?= <lookup>.
    endif.

- Rasmus

Read only

uwe_schieferstein
Active Contributor
0 Likes
4,560

Hello Rasmus

Looking at the coding of fm BICS_CONS_EXECUTE_PLANNING_FUN I would say you cannot access L_R_DATA_PROVIDER because it is a local variable.


FUNCTION bics_cons_execute_planning_fun.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(I_FUNCTION_HANDLE) TYPE  RSBOLAP_HANDLE
*"  EXPORTING
*"     VALUE(E_MAX_MESSAGE_TYPE) TYPE  SYMSGTY
*"     VALUE(E_EXECUTED) TYPE  RS_BOOL
*"     VALUE(E_DATA_AREA_CONTAINS_DATA) TYPE  RS_BOOL
*"  TABLES
*"      E_T_MESSAGE STRUCTURE  BICS_PROV_MESSAGE OPTIONAL
*"      I_T_STATISTIC_INFO STRUCTURE  RSSTA_S_EVENTINPUT OPTIONAL
*"      E_T_OUT_OF_SYNC_DP STRUCTURE  RSBOLAP_S_OBJECT_NAME OPTIONAL
*"  EXCEPTIONS
*"      INVALID_FUNCTION_HANDLE
*"      VARIABLE_INPUT_NECESSARY
*"----------------------------------------------------------------------

* Begin of the rfc function module
  rfc_function_module_start 'BICS_CONS_EXECUTE_PLANNING_FUN' i_function_handle.

  DATA:
    l_r_data_provider         TYPE REF TO if_rsbolap_data_provider,  " <<< local variable
    l_r_function              TYPE REF TO cl_rsplfr_web_start_service,
    l_invalid_function_handle TYPE rs_bool,
    l_s_mesg                  TYPE rrms_s_mesg,
    l_t_mesg                  TYPE rrms_t_mesg,
    l_t_names                 TYPE RSBOLAP_T_OBJECT_NAME,
    l_s_name                  type rsbolap_s_object_name.

* Get the data provider
  l_r_data_provider = 
    cl_rsbolap_application=>get_data_provider_static( i_handle = i_function_handle ).
...

The variable would be accessible if it were global, i.e. defined in the TOP-include.

The main program SAPLRSBOLAP_BICS_CONSUMER does not know anything about local variables within the function modules.

Regards

Uwe

Read only

0 Likes
4,560

Of course, you are quite right.

How about the import parameters should I be able to access them.

E.g. I_FUNCTION_HANDLE?

Read only

0 Likes
4,560

Yes you can get an access of the importing parameter.

Try like this:


  ld_class = '(SAPLRSBOLAP_BICS_CONSUMER)I_FUNCTION_HANDLE'.
  ASSIGN (ld_class) TO <lo_provider>.

I didn't realize that L_R_PROVIDER is local variable and hence we can't access it. I apologize for that.

Regards,

Naimesh Patel

Read only

0 Likes
4,560

Hello Rasmus

Most likely the answer is again: NO.

Why?

Looking at the "Attributes" tabstrip of fm BICS_CONS_EXECUTE_PLANNING_FUN you can see that the flag "Global" is NOT set. Thus, the interface parameters are NOT globally visible in the function group.

Regards

Uwe

Read only

0 Likes
4,560

Not working with the import parameter aswell.

- Rasmus

Read only

0 Likes
4,560

Allright, who said it was going to be easy.

How about line no. 5.

this also holds the information that is need

But now it is a method call in a class.

Is it possible to get this class ?

CL_RSPLFR_WEB_START_SERVICE===CP

And how should it be written?

Read only

0 Likes
4,560

The class has a public attribute called n_handle which should reflect the I_FUNCTION_HANDLE from earlier.

I have tried 2 get it but unsuccesfull.

Here is what i have tried.


    lookup_string = '(CL_RSPLFR_WEB_START_SERVICE===CP)N_HANDLE'.
    ASSIGN (lookup_string) to <lookup>.
    lookup_string = '(CL_RSPLFR_WEB_START_SERVICE)N_HANDLE'.
    ASSIGN (lookup_string) to <lookup>.
    lookup_string = '(CL_RSPLFR_WEB_START_SERVICE)IF_RSBOLAP_DATA_PROVIDER~N_HANDLE'.
    ASSIGN (lookup_string) to <lookup>.
    lookup_string = '(CL_RSPLFR_WEB_START_SERVICE===CP)IF_RSBOLAP_DATA_PROVIDER~N_HANDLE'.
    ASSIGN (lookup_string) to <lookup>.

All the time <lookup> does not get assigned. Any ideas ?

Read only

0 Likes
4,560

Bump

Read only

0 Likes
4,560

Still looking for a solution to this problem.

Read only

0 Likes
4,560

Wow, first posted in June. I admire your persistence.

Unless I've missed something, this seems very straightforward. If n_handle is a public static attribute, you can get it directly, without needing the assign, or accessing the call stack.:

DATA: l_handle TYPE RSBOLAP_HANDLE.

DATA: l_r_data_provider TYPE REF TO if_rsbolap_data_provider

l_handle = CL_RSPLFR_WEB_START_SERVICE=>N_HANDLE. " you don't need the interface qualifier as this attribute is aliased
l_r_data_provider = cl_rsbolap_application=>get_data_provider_static( i_handle = l_handle ).

matt

Read only

0 Likes
4,560

The attribute is not a static attribute but an instance variable.

Br Rasmus

Read only

0 Likes
4,560

Hello Rasmus,

have you already considered implementing the implicit enhancement point at the beginning of function module BICS_CONS_EXECUTE_PLANNING_FUN? You could write the value of I_FUNCTION_HANDLE to memory and access this value later in your code. If you have the handle, you can call the static method GET_DATA_PROVIDER_STATIC of class CL_RSBOLAP_APPLICATION to receive the desired object instance.

Regards,

David