Application Development and Automation 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: 
Read only

Dynamic Where clause

Former Member
0 Likes
567

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'.

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
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
539

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

Read only

Former Member
0 Likes
539

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

Read only

0 Likes
539

Hi,

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

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

Regards

Olaf