cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic WHERE clause in SELECT statement

Former Member
0 Kudos

Hi,

I need to extract (SELECT) all the products in different salesorganizations. Since a product can be available in more than 1 salesorg I have created several properties in the PRODUCT dimension - 1 for each salesorganization (naming: Sxxxx where xxxx is the salesorganization number).

Since I need to prefix the salesorganization property with an "S" I have created a property on the SALESORG dimension called SALESORG.

Therefore I need to create a dynamic WHERE clause in the SELECT statement. Currently my script is:


*SELECT(%SORG%, "[SALESORG]",SALESORG, [ID]=%SALESORG_SET%)
*SELECT(%PROD%, "[ID]",PRODUCT, [%SORG%]="X")

My first SELECT find the Sxxx (equal to the property I need in the PRODUCT dimension). My second SELECT uses the variable in the first SELCT statement to use the correct property for the WHERE clause.

Unfortunately the code is not validated - any suggestions?

/Lars

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Yes - no problem here. The problem exist when I try to validate the second SELECT statement.

/Lars

esjewett
Active Contributor
0 Kudos

Hi Lars,

If you run it from a DM package without validating it, does it still work? I would bet it does.

If this is the case I would open a message with SAP (it would be an enhancement request). Until they fix the validation code, you would just have to live with the script not validating.

Cheers,

Ethan

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Have you tried only the first select in your script? Does that validate (only the first select statement) ?

Former Member
0 Kudos

Hi,

Fair enough.

Can I somehow make sure I only receive 1 value (passed from a DM package)? This is what's going to happen, since the users can only select 1 member in the DM package (different value for diffenrent user - so hardcoding is not an option).

/Lars

Former Member
0 Kudos

Hi,

The problem is with the second select statement.

When the first select statement is executed, you might get multiple values in %SORG%. Something like: X,Y,Z.

Now, in the second select statement, you are using [%SORG%] = "X". However, this statement will be treated as [X,Y,Z]= "X". And this is wrong. Thats why the second select statement is not supported.