cancel
Showing results for 
Search instead for 
Did you mean: 

Complex BEX Variables with CMOD

Former Member
0 Kudos

Hi,

I am trying to generate AND and OR condition for 5 products in my transactions. I have 5 product fields for each transaction. I should be able to have 2 selection variable filter and based on that selection i should be able to get only those records that have both the selected filter variables in any of the 5 products.

Variable 1 - 123

Variable 2 - 345

SAMPLE DATA :


TransID  Prd1  Prd2  Prd3  Prd4  Prd5
001      123   234   345    -     -
002       -    234   345    -    123
003       -    657   876    -     -
004      123   098    -    246    -
005      123    -     -    345    -
006      333    -     -    222    -

I should get only the result with TransID 001,002,005 because it had 123 and 345 in any of the 5 Products

I am able to generate results with OR condition showing only TransID 001,002,004,005.I handled this scenario with 5 customer exit variables based on 5 produts and 2 selection variable and retrieving the data and populating the 5 customer exit variables.

Any brilliant idea will be fully rewarded.

Thank you

Arun

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Ajay,

I am really confused why are you defining formula variables based on products, it may contain alphabets.

Thank you

Arun

Former Member
0 Kudos

Hi Arun,

You can do the following :

Create two formula variables with user-exit processing, in the user-exit code, assign your selection values to these formula variables. (This is to make the selection variable values available in formulas). Let us say these are fv1 and fv2 (in your example fv1 = 123 and fv2 = 345)

Now define a set of formulas :

Formula11 = 1 * boolean (kf1 == fv1)

formula12 = 1 * boolean (kf2 == fv1)

.... till formula15

These formulas will result in either 0 or 1 depending on whether the products are equal to fv1 (123).

Similarly create another set of formulas to compare the kfs with second variable value

formula21 = boolean (kf1 == fv2)

formula22 = boolean (kf2 == fv2)

.....

Now make another formula/kf

formula = bool ( (formula11 + formula12 .... formula15) <> 0)

*

bool ( (formula21 + formula22 + ....formula25) <> 0)

This formula value of 1 means your both conditions are met. So you can set a condition on this formula field in your query to display the records when the value of this formula is 1.

This way you can do everything in your query itself.

hope this helps,

cheers,

Ajay

Former Member
0 Kudos

Hi Dirk Herzog,

Is there any document available which explains how to use the BADI implemantion with class?

Where do you use this generated class, are you referrring to MODIFY_CLASS?

Thank you

Arun

Former Member
0 Kudos

I have a weblog on this topic in work, but it will appear end of this month.

With the generated class I mean the class that is generated during BAdI creation.

Best regards

Dirk

Former Member
0 Kudos

Arun,

the only thing I'm not understanding is on which char are you build your 2 selection variables ?

Former Member
0 Kudos

Hi Roberto,

Can you explain further to handle this scenario?

I don't understand do you want me to create 5 Virtual Keyfigure and create variable based on them?

Thank you

Arun

Former Member
0 Kudos

Hi Arun,

here is an idea of implementation.

1. Create a BAdI implementation of RSR_OLAP_BADI.

2. In the generated class, define two static attributes, PRODUCT_1 and PRODUCT_2.

3. In the variable user exit, during step 3 you can read the variable values and store them in the static attributes.

4. In the DEFINE implementation choose your 5 products as read mode and a new characteristic PRODEX (products exist) as mode no selection.

5. In the COMPUTE implementation you can compare the values of the static attributes to the 5 products. If they both exist set PRODEX = '+' else set PRODEX = '-'.

(Don't leave it empty, it's easier for testing if the BAdI works).

6. In your query, filter on PRODEX = '+'.

Best regards

Dirk

Former Member
0 Kudos

Arun,

I think it's easier to manage this scenario with a virtual KF (from which you are able to see your input variables) as a flag (for example) and then use it to create a condition on your query...

This is just my first thought...

Hope it helps!

Bye,

ROberto