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 check

ashwin_mundkur
Product and Topic Expert
Product and Topic Expert
0 Likes
708

Hi,

I have around 5 fields which has to be checked in an Internal table. It is an AND condition.

I developed the logic to build the dynamic where clause by checking each of the 5 variables.

In one of the cases the where clause looks as below.

Lt_where_clause = ' AND PRODUCT_TYPE CP LV_PRODUCT_TYPE

AND PRODUCT_ID CP LV_PRODUCT_ID

AND CATEGORY_ID CP LV_CATEGORY_ID

AND PRODUCT_TEXT CP LV_PRODUCT_TEXT.'

Now I want to send this to

LOOP AT LT_PRODUCTS WHERE lt_where_clause.

...

ENDLOOP.

System doesnt allow me have a dynamic where clause. Does anyone have an idea how can the internal table be checked with dynamic where clause.

thanks,

Ashwin

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
654

Taken from F1 help on LOOP statement.

Dynamic specification of a component through bracketed character-type data objects is not possible.

You care going to have to have conditional IF statements inside your LOOP statement.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
654

Try this..

1)Build your code.

2)Use GENERATE SUBROUTINE POOL statement to generate the code at runtime.