Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
gdey_geminius
Contributor

Introduction:


The importing parameter "I_S_RKB1D"(query attribute) is not getting filled for authorization variable(I_STEP=0) in the FM "EXIT_SAPLRRS0_001"(FM for customer exit variable). Recently I have faced this issue in our system and came up with a workaround and thought to share it so that it will be helpful for someone who is having the same issues.

Problem Statement:


In customer exit/BAdI for BEx Variable, we often have requirements to get the query related attributes (e.g., ID of the query) so that we can mold our code accordingly. We already have an importing parameter(I_S_RKB1D in case of customer exit) for the query attributes in the FM/Class of the Customer exit/BAdI respectively. The importing parameter works fine for customer exit variables for I_STEP=1 and 2(work fine in the sense, the query id is filled in the imparting parameter). However, for authorization variables(that is when the value of I_STEP is 0), the values are not filled in the query attributes and remain blank. 

Below screenshot for reference. We can see the variable "I_VNAM" which have the value for authorization variable name, "I_STEP" which have the value "0" which is for authorization check. We can see the value of the variable "I_S_RKB1D-COMPID" is empty, which should have the value of the query being run.

(The above screenshot is from the function module "EXIT_SAPLRRS0_001" which belongs to the customer exit "RSR00001"-BI: Enhancements for Global Variables in Reporting).

We can see in the below screenshot, the value of I_STEP is "2" and the query id is populated successfully in the variable "I_S_RKB1D-COMPID".

So, to summarize the issue, the query ID is not getting populated for Authorization Variable (I_STEP=0) but, it is working fine for the customer exit variable(I_STEP =1 or 2).

Proposed Solution:


There is a standard class "CL_RSBOLAP_SELECTION_OBJECT" which is responsible for calling the customer exit/BAdI for authorization/customer exit variable of BEx. The class has an attribute "IF_RSBOLAP_MD_SELECTOR~N_S_COMPKEY" which stores the query attributes of the query which is being run.

So, we can take the help of the "static attribute" of Object-Oriented Programing. We will create a custom class and create a static attribute in the class for the query id. We set the value of query attribute from this class using a "Pre-exit" in the method. Then inside the customer exit/BAdI, we can use our custom class to get the query Id.

Those who are new to Object-Oriented programming, static attributes are the attributes of the class which are not associated with the object of the class directly and exists on per class basis. Which means, there will be only one instance of the attribute for one class and these attribute can be accessed without creating the object of the class. For more information, please refer to the below link.

https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapclass-data.htm

As mentioned already, we will be creating a pre-exit in the class of the method. Pre-exit is nothing but the enhancement technique, where we can associate our code to the class which will be called automatically by the system whenever that particular method is called anywhere. As this is the pre-exit, so our code will be called followed by the code of the standard method. For more information, please refer to the below link

https://wiki.scn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enhancements+-+Pre-exit,+Po...

So, let's start.

Step 1: Creation of custom class


Let's create a custom class "ZCL_BW_QUERY_NAME". This class will be used to get the Query Id. This class will have below component:Attribute:

  • MV_QUERY_ID -  To store the query Id




Methods:

  • SET_QUERY_ID - Sets the query ID - This will be used in the Pre-exit of the method of class "CL_RSBOLAP_SELECTION_OBJECT" to set the value

  • GET_QUERY_ID - Gets the query ID - This will be used in customer exit/BAdI to get the query id




Method: SET_QUERY_ID
  METHOD set_query_id.
"Set the query id
mv_query_id = im_v_query_id.
ENDMETHOD.

Method: GET_QUERY_ID
  METHOD get_query_id.
"Return the query id
rt_v_query_id = mv_query_id.
ENDMETHOD.

Step 2: Creation of pre-exit for setting the value of Query in the custom class


To create the Pre-exit go to the class "CL_RSBOLAP_SELECTION_OBJECT" in class builder(t-code: SE24) and click on "Class--> Enhance" in the menubar.

If you have already an enhancement implementation, then the created enhancement implementation will be shown in the pop-up. Select the implementation to proceed. In my case, there is no existing implementation, so I will go ahead and create one.

Once the Enhancement Implementation is created, place the cursor on the method "CREATE_OLAP_OBJECT". Then create a pre-exit method.

Please click on "Yes" in the pop-up if the pop-up is displayed.


Now click on the button shown in "Pre-exit" column of the method "CREATE_OLAP_OBJECT".

Please add below code inside the pre-exit of the method method
METHOD IPR_ZEHN_QUERY_DETAILS~CREATE_OLAP_OBJECT.
*"------------------------------------------------------------------------*
*" Declaration of PRE-method, do not insert any comments here please!
*"
*"methods CREATE_OLAP_OBJECT
*" importing
*" !I_AUTHCHECK type RS_BOOL
*" raising
*" CX_RSBOLAP_UNKNOWN_DATA_PROV .
*"------------------------------------------------------------------------*
"Set the query ID
zcl_bw_query_name=>set_query_id( im_v_query_id = core_object->if_rsbolap_md_selector~n_s_compkey-compid ).
ENDMETHOD.

So, we have created the custom class and set the query Id. We are all done. No kidding. Now we can use our method "GET_QUERY_ID" of our class "ZCL_BW_QUERY_NAME" inside customer exit to fetch the query id.

Step 3: Get the query id in customer exit 


Now, let's go our customer exit for BEx Variable to use our class to get the query id. Let's
IF i_s_rkb1d-compid IS INITIAL.
"Get the query id
i_s_rkb1d-compid = zcl_bw_query_name=>get_query_id( ).
ENDIF.

We can call the method "GET_QUERY_ID" of the class "ZCL_BW_QUERY_NAME". We can see we get the name of the query in the which is being run. Please note the value of "I_STEP" is "0", which confirms we are dealing with the authorization variable.

Conclusion:


As we saw, we had an issue to get the Query Name for the authorization variable(I_STEP=0). The I_S_RKB1D-COMPID was blank. However, for I_STEP=1 or 2, there is no issues and the variable "I_S_RKB1D-COMPID" is filled correctly. To overcome the issue, we have created a pre-exit in the method "CREATE_OLAP_OBJECT" in the class to set the query id in the custom class "ZCL_BW_QUERY_NAME". Then, we used the class "ZCL_BW_QUERY_NAME" in the customer exit(for BAdI also it will work fine) to get the name of the query. Cheers!
4 Comments
Labels in this area