cancel
Showing results for 
Search instead for 
Did you mean: 

BEx Query Pass Value to Variable/Customer Exit

TobiasMeinzer
Advisor
Advisor
0 Kudos

Hi Experts,

I want to gather an attribute via a SQL statement that is not part of the InfoProvider with the help of a customer exit variable.

The problem is that this attribute depends on the line item ID in the query (imagine having several line items with different IDs and each line item has its specific attribute value).

How can I pass the line item ID from the query to the customer exit in order to perform a SQL statement based on the line item ID?

The result should look like the following table:

Line Item IDAttribute Value
1X
2Y
3Z
4Y

Thanks for your support!

Tobias

Accepted Solutions (1)

Accepted Solutions (1)

yasemin_kilinc
Active Contributor
0 Kudos

Hi Tobias,

To pass the value of ID to your customer exit, you can follow this procedure:

Create a formula variable (say ZVAR1) with replacement path using line item ID, select replace variable with as infoobject and replace with as key. Then in the customer exit in i_step = 2 you can read its value by this little code:

loop at i_var_range into ZVARIABLE where vnam = 'ZVAR1'.

zvariable will have the value of line item id.

Hope it helps

Yasemin...

Former Member
0 Kudos

Hi Yasemin,

Following up on your solution, will your solution work for each line of the BEx output .

I doubt this because I_step = 2 code does not get executed for each record of the bex output.

Yasemin I would like you to correct me if I am wrong in my above explanation.

Now coming back to the solution to this post ( I am assuming that you do not want to add that attribute as part of your infoprovider):

1) use virtual char and at the run time fetch the attribute values. But this will hamper your report performance.

2) make an infoset between the info provider and the line item infoobject and fetch that attribute . but this is also not recommended as using infoset is outdated and is not good for a longer run and value discrepancies may appear due to inner join.

Regards,

Ashutosh

TobiasMeinzer
Advisor
Advisor
0 Kudos

Hi Yasemine & Ashutosh

many thanks for your reply.

I even tried the "step 2 solution" yesterday but I could not get the ID variable from the VAR_RANGE table in step 2. The table only contains variable 0DAT which I do not use anyway in my query.

I am looking for a solution without touching the InfoProvider data model in the backend. Isn't there any other way? As far as I understood the virtual characteristic solution, I would have to enhance the InfoProvider?

Thanks for your support on this topic!

Tobias

Former Member
0 Kudos

Hi Tobias,

Yes I_step = 2 will not work here because it detects variables filled during I_step = 1 mode. And this formula variable does not get filled in I_step = 1 mode.

That is why you are not able to find this variable in VAR_RANGE table.

In the infoset solution you don't have to enhance anything in your existing infoorovider. Its just that you have to link it via an infoset to that line item infoobject using inner join.

And build you bex query on top of infoset.

I am afraid that you might have to deal with modelling changes.

Figure out your approach now. Over virtual characteristics I would say give it a shot to infoset (though Both are not recommended)

Regards

Ashutosh

yasemin_kilinc
Active Contributor
0 Kudos

Hi Ashutosh and Tobias.

You are definitely right that we can't use it in i_step 2. It would be i_step 1. Even, if we try to use it in i_step 1, the value of formula variable wouldn't be filled in. I just remembered a case where I tried this scenario. I thought it was successfull but was not in fact. Tobias, what you can do is writing this code in the start routine in transformation.

Thanks for the info Ashutosh.

Regards

Yasemin...

Former Member
0 Kudos

You are welcome yasemin !!

Yes do a data reload and use read master data in transformation or make it a navigational attribute .

Regards,

Ashutosh

TobiasMeinzer
Advisor
Advisor
0 Kudos

Hi all,

so I fetch the attribute values now using a virtual characteristic and the BAdI Implementation.

Thanks for your support!

Tobias

Answers (2)

Answers (2)

sascha_reissig
Participant
0 Kudos

Hi Tobias,

I'm not really sure if I undestand your requirement well. But alternatively to use virtual keyfigures/chars you can check out if you can use an InfoSet to link your line item object of your CUBE/DSO to the info object with your attributes - then put it into a MultiProvider where the query runs.

regards, Sascha

dielom
Active Contributor
0 Kudos

Hi Tobias,

a BEx variable will not help.

You have two alternatives:

- Use a virtual characteristic (a user exit where you will receive a table with your line item IDs and you can then populate teh attribute values for each one of them).

- Use a navigational attribute on item ID (load previously to reporting).

The second option will provide better performance, given that the attribute for the line item ID does not depend on any other values.

Hope this helps.,

Cheers,

Diego