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: 

FM/method create dynamic where condition

Former Member
0 Kudos
3,285

Hello everyone!

i want to create a dynamic where condition, (BI related) to create a select for every extractor. But this is just additional information

Though i need to create a dynamic where condition to have generic selects.

Actually i use FM CRS_CREATE_WHERE_CONDITION. But this FM got a restriction. When i want to have a where condition like:

WHERE TEXT CP 'A**'

this FM masks the * with #* and this leads to the result that i only get texts containing the string 'A*' and not every text starting with A.

Though i tried FM RH_DYNAMIC_WHERE_BUILD because it was recommended very often here in the forum-discussions.

But this FM can only work with Fields shorter than 20 signs. And it also can not work with SIGNS, so only SIGN = I is possible.

the most disadvantage is that it creates a where condition that can not be used for SQL-Select statements. Because in a SQL Statement you can not write TEXT EQ 'A*'  -> you need to write TEXT = 'A*'.

i also had a look on FREE_SELECTIONS_INIT. but this seems to be something different. But looking to the function Group of this FM i found the FM FREE_SELECTIONS_RANGE_2_WHERE. But this FM also does not produce legit SQL Where-Statements.

can you help me out? do you know any methods / FMs beside these to create dynamic where condition?

the where condition i need is for this statement:

OPEN CURSOR WITH HOLD ca_curser FOR SELECT * FROM (pi_table_name)
       WHERE (ca_t_where_condition).                    

regards

Stefan Seebruger

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos
1,588

Why do you need an existing function module? Isn't it more simple to build it from scratch by concatenating strings?

0 Kudos
1,588

we use standard coding wherever we can.

0 Kudos
1,588

In that case, I doubt CRS_CREATE_WHERE_CONDITION and RH_DYNAMIC_WHERE_BUILD are supported by SAP (only very few function modules are released) and they may be deleted in a future release without warning (although it's not so frequent). FREE_SELECTIONS_RANGE_2_WHERE being the only released function module, so go for it! What issue do you have with it exactly?

0 Kudos
1,588

In this statement: WHERE (ca_t_where_condition),

its not legit to have OPERATORS LIKE "EQ" "CP"... It will result in a Dump/exception.

I need "=" and "LIKE"-Operator and stuff. but the method FREE_SELECTIONS_RANGE_2_WHERE does not create a legit string for my where-condition.


I did not solve this issue, but i found out, that i dont need *-Search in my dynamic where clause of FM CRS_CREATE_WHERE_CONDITION because SAP-BI-API does not allow it in INIT-LOAD either.so i dont have to search for different methods/FMs


I left this thread open because it would be good to know for future tasks.


Regards

Stefan Seeburger