cancel
Showing results for 
Search instead for 
Did you mean: 

BAdi RSR_OLAP_BADI and RSDRI_INFOPROV_READ

Former Member
0 Kudos
272

Hi folks,

I try to use the RSR_OLAP_BADI to compute virtual key figures. These key figures are based on a lookup in an Info Cube which I do in the COMPUTE method of the implementation class. In this method I call the function module RSDRI_INFOPROV_READ for reading data out of an Info Cube. In some cases I get the error message

It seems that the function module has an internal state which would be overwritten through the invocation in the COMPUTE method.

Has anyone an idea how to prevent this? Or is there a better way to read from an Info Cube??

Thanks a lot for any advices!

Rgds,

Juergen

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Jürgen,

how often do you call the RSDRI_INFOPROV_READ? If possible you should call it only once and buffer all the data you need. The error message seems to indicate that the RSDRI_INFOPROV_READ (which is also used for query extraction) cannot be executed multiple times within itself.

My suggestion would be to wrap the RSDRI_INFOPROV_READ into a wrapper class that buffers the data and call the method during step 3 of the variable exit.

Best regards

Dirk

former_member93896
Active Contributor
0 Kudos

Jürgen,

as it has been pointed out already and as the error message says, you can't call RSDRI_INFOPROV_READ in this BADI. It does not make sense anyway for performance reasons, since the BADI is called once for each record but you certainly don't want to read the other InfoCube so often. Ideally there should be no database access within the COMPUTE method. Otherwise you will run into performance problems when users select a lot of data.

I agree with Dirk. Do the RSDRI_INFOPROV_READ once in the variable exit, buffer the results in memory, and read whatever you need from memory in the COMPUTE method.

Regards,

Marc

SAP NetWeaver RIG

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Jürgen,

RSDRI_INFOPROV_READ cannot be called twice in the same context, because then some static variables would be overwritten. In your case it is called once by the query you are executing and a second time (for a different cube, but that does not matter) during your calculation of the virtual key figures. In that case you get the error message indicating a nested call.

I have not tried yet, just an idea: is it possible to call your function module by CALL FUNCTION ... STARTING NEW TASK (asynchronous RFC)? In the ABAP documentation it is described how to receive results from asynchronous calls in topic RECEIVE RESULTS FROM FUNCTION

Hope that helps

Stephan

Former Member
0 Kudos

Hi,

thanks all for your quick answers. I prefer using the RFC call. I found out that I have to use RSDRI_INFOPROV_READ_RFC instead to use an RFC capable function module. This also means that I have to call RSDRI_DATA_UNWRAP to get the result in an internal table.

The structure of that internal table must be "/BIx/V 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at l_t_data into wa_data.

move-corresponding wa_data to wa_vjwerte.

  • --> here it it's comp S008 in production it's S019!!!

wa_vjwerte-0MATERIAL__ZRTLOSORT = wa_data-S008_0MATERIAL.

wa_vjwerte-0PLANT__ZRTZBART = wa_data-S005_0PLANT.

wa_vjwerte-0PLANT__0SALES_DIST = wa_data-S009_0PLANT.

append wa_vjwerte to m_t_vjwerte.

endloop.

ENDWHILE.

former_member93896
Active Contributor
0 Kudos

Hello Jürgen,

if InfoCube and characteristics are the same in Dev and Prod, then the /bix/v...2 structures should also be the same. If not, I would consider it a bug.

Anyway, you can use ASSIGN to move the attributes:

FIELD-SYMBOL .

...

Regards,

Marc

SAP NetWeaver RIG

Former Member
0 Kudos

You could also use the dynamically assigned attributes.

When you create the BAdI you should go to Goto->Sample Code->Copy. You can then add the attributes P_CHA_<IOBJ> and P_KYF_<IOBJ> as static instance attributes type I to the system. You can then access them in the COMPUTE method with the following meaning:

value = 0 - Info Object is not in the query (and not defined as read_mode)

value <> 0 - component in the c_s_data structure.

So it would be


IF P_CHA_0FISCPER > 0.
  ASSIGN COMPONENT P_CHA_0FISCPER 
    OF STRUCTURE c_s_data
    TO <f_fper>.
  <f_fper>+4(3) = '012'.
ENDIF.

(Code copied from another sample).

Best regards

Dirk

Former Member
0 Kudos

Sorry, I forgot the error message:

You are executing a nested query. That is not possible.

(translated from German by myself:-)