2010 Mar 10 7:31 PM
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
2010 Mar 10 8:42 PM
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
2010 Mar 10 10:59 PM
Hi,
<li>Define ranges tables like below.
<li>Build 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>Create dynamic WHERE clause 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.
Let me know if you get any problem.
Thanks
Venkat.O
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.
2010 Apr 15 5:40 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |