Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Where clause

Former Member
0 Kudos

Hey Guys,

I want to create the dynamic where clause.

DATA: GI_WHERE(72) OCCURS 0 WITH HEADER LINE.

SELECT *

INTO TABLE GI_VBAK

FROM VBAK

WHERE (GI_WHERE).

In that where clause contain ranges.

for eg.

GI_WHERE = 'VBELN IN S_VBELN'.

3 REPLIES 3

0 Kudos

Hi,

You can do this by building a String of what you want to put in the where clause.

Ex:

DATA: where_string type string.

concatenate where_string 'VBELN IN S_VBELN' into where_string separated by space.

Use it like this

SELECT * FROM table_name into table it_tab where ( where_string ).

Best Regards,

Sesh

Former Member
0 Kudos

Hi,

follow below logic.

data lv_str type string value 'GI_WHERE'.

lv_str1 type string value 'VBELN IN S_VBELN'.

DATA: GI_WHERE(72) OCCURS 0 WITH HEADER LINE.

CONCATENATE lv_str ' = '''lv_str1'''' '.'

INTO gi_where.

APPEND gi_where.

SELECT *

INTO TABLE GI_VBAK

FROM VBAK

WHERE (GI_WHERE).

Regards

amole

0 Kudos

Hi,

you can't use the "in" within a dynamic clause.

Please refer to ABAP-keyword documentation of dynamic logical condition.

Regards

Olaf