Skip to Content
0
Former Member
May 26, 2012 at 08:18 PM

Using dynamic where clause with dynamic table...

414 Views

Hi,

I have a requirement. I am working in a user exit in which there is a table parameter C_T_DATA whose structure is defined at runtime only based on some conditions. Lets say, if cond1 is true, structure will be ABC; else it will be XYZ.

Now, in my code, i need to use SELECT query based on the value populated in internal table. So i wrote the code like below :

DATA : v_where TYPE string.

If cond1 is true.

v_where = 'GUID = C_T_DATA-GUID'.

SELECT partner_guid

from BUT000

into table it_partner

FOR ALL ENTRIES IN c_t_data

WHERE (v_where).

elseif cond2 is true.

v_where = 'VBELN = C_T_DATA-VBELN'.

*----Corresponding Code

endif.

Now, when I am executing the code, I am getting a short dump saying only literals are allowed in dynamic where and not values. So anyone could please help me out to solve this. I found some posts for this but in all those the structure of table was known while in my case it is known at run time only.

Kindly help.

Regards,

Guddan