I'd like to build a select where the components are dynamic. This is what I have so far and what works for simple selects:
"Select is enclosed in TRY...ENTRY to catch any Syntax-errors
"related to the dynamic where-clause provided in P_WHERE
INTO TABLE <t_in_itab>
CATCH cx_sy_dynamic_osql_syntax cx_sy_dynamic_osql_semantics
If P_TABN is filled with T001 and the below where-clause is provided, the correct data is selected and put into the itab <t_in_itab>:
BUKRS EQ 'DE50' OR BUKRS EQ 'AT10' OR BUKRS EQ 'PL10'
Now, I want to do something similar with table LIPS but where the actual selection is happening on LIKP-data.
P_TABN is filled with LIPS and the where-clause looks as follows:
VBELN IN ( SELECT VBELN FROM LIKP WHERE VKORG EQ 'DE10' OR VKORG EQ 'PL10' )
When I execute this, I get the CX_SY_DYNAMIC_OSQL_SEMANTICS exception with this error-message:
Could not interpret the value 'SELECT'
If I have the coding in "plain" writing it does work:
INTO table t_lips
WHERE VBELN IN
( SELECT VBELN FROM LIKP WHERE VKORG EQ 'DE10'
OR VKORG EQ 'PL10' ).
Is my coding wrong or is there simply a hard and fast rule which prohibits sub-selects from being used in dynamic selects? I tried to find something in SCN and elsewhere but didn't happen upon a "yes/no" type of answer.
Thanks for any insights you have!