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

using FREE_SELECTIONS_RANGE_2_WHERE

Former Member
0 Likes
2,705

Hi,

I am trying to use ranges in the where clause of my select statement.

The inputs I have is an internal table say t_selflds of type RSTI_T_PAR. So if I have 2 selection options filled with values such as

sopt1 = 10 or

sopt1 = 20

sopt2 is between 20 and 50

then the values in t_selflds will be like

selname kind sign option low high

sopt1 I EQ 10

sopt1 I EQ 20

sopt2 I BT 20 50

Now I want to form a dynamic where clause using these values such that my where clause shud be like 'sopt1 IN range1 and sopt2 IN range2'.

So range1 and range2 are to be formed dynamically.

I read that we can use FREE_SELECTIONS_RANGE_2_WHERE. not sure how to form the field_ranges for this FM.

Can anyone guide me how to move the values from my t_selflds to field_ranges ?

Or if there is any other simple way to form the dynamic where clause with ranges for multiple fields, pl share.

thks

Hi,

I am trying to use ranges in the where clause of my select statement.

The inputs I have is an internal table say t_selflds of type RSTI_T_PAR. So if I have 2 selection options filled with values such as

sopt1 = 10 or

sopt1 = 20

sopt2 is between 20 and 50

then the values in t_selflds will be like

selname kind sign option low high

sopt1 I EQ 10

sopt1 I EQ 20

sopt2 I BT 20 50

Now I want to form a dynamic where clause using these values such that my where clause shud be like 'sopt1 IN range1 and sopt2 IN range2'.

So range1 and range2 are to be formed dynamically.

I read that we can use FREE_SELECTIONS_RANGE_2_WHERE. not sure how to form the field_ranges for this FM.

Can anyone guide me how to move the values from my t_selflds to field_ranges ?

Or if there is any other simple way to form the dynamic where clause with ranges for multiple fields, pl share.

thks

3 REPLIES 3
Read only

Former Member
0 Likes
1,497

Hi,

execute this function module in SE37 - in test environment,

system will generate structures to needed to fill table which is parameter.

You will see there, where you should put table, field name and values from ranges.

Everything is clear in this generated screen.

Regards,

--

Przemysław

Read only

venkat_o
Active Contributor
0 Likes
1,497

Hi, <li>Define ranges tables like below.


DATA:t_range1 TYPE RANGE OF xyz-sopt1.
DATA:w_range1 LIKE LINE OF t_range1.
DATA:t_range2 TYPE RANGE OF xyz-sopt2.
DATA:w_range2 LIKE LINE OF t_range2.
"Please replace xyz with your database table name here.t
<li>Build ranges tables like below.
w_range1-low    = '10'.
w_range1-sign   = 'I'.
w_range1-option = 'EQ'.
APPEND w_range1to t_range1.
clear  w_range1.

w_range1-low    = '20'.
w_range1-sign   = 'I'.
w_range1-option = 'EQ'.
APPEND w_range1to t_range1.
clear  w_range1.

w_range2-low    = '10'.
w_range2-high    = '20'.
w_range2-sign   = 'I'.
w_range2-option = 'BT'.
APPEND w_range2to t_range2.
clear  w_range2.
<li>Create dynamic WHERE clause like below.

DATA:str TYPE string.
str = 'sopt1 IN range1 and sopt2 IN range2'.
"Use this STR variable in dynamic where clause.
SELECT * 
  FROM xyz
  INTO table it_xyz
WHERE (str).
"(str) contains 'sopt1 IN t_range1 and sopt2 IN t_range2' at runtime.
Let me know if you get any problem. Thanks Venkat.O

Read only

Former Member
0 Likes
1,497

solved using FREE_SELECTIONS_RANGE_2_WHERE.