2009 May 27 11:06 AM
Hi!
I got the following question:
I'd like to use a SELECT statement which depends on a parameter of selection screen.
So as an example:
if p_a EQ 'X'
the select-statement should be:
SELECT * FROM tbl WHERE abc IN ('a','b','c')
if p_b EQ 'X'
the select-statement should be
SELECT * FROM tbl WHERE abc IN ('d','e','f')
how can i handle this problem?
Is it possible to solve this with one select-statement?
something like:
SELECT * FROM tbl WHERE abc IN variable
where i can fill my variable depending on parameter?
Regards,
Jacko
2009 May 27 11:09 AM
Hi,
It is very simple.
Please make use of RANGES or an internal table similar to structure of a select-options.
Regards,
Ankur Parab
Hi!
I got the following question:
I'd like to use a SELECT statement which depends on a parameter of selection screen.
So as an example:
if p_a EQ 'X'
the select-statement should be:
SELECT * FROM tbl WHERE abc IN ('a','b','c')
if p_b EQ 'X'
the select-statement should be
SELECT * FROM tbl WHERE abc IN ('d','e','f')
how can i handle this problem?
Is it possible to solve this with one select-statement?
something like:
SELECT * FROM tbl WHERE abc IN variable
where i can fill my variable depending on parameter?
Regards,
Jacko
2009 May 27 11:09 AM
Hi,
It is very simple.
Please make use of RANGES or an internal table similar to structure of a select-options.
Regards,
Ankur Parab
2009 May 27 11:14 AM
data: lr_abc type range of char10,
ls_abc like line of lr_abc.
if p_a = 'X'.
ls_abc-low = 'A'.
ls_abc-sign = 'I'.
ls_abc-option = 'EQ'.
append ls_abc to lr_abc.
ls_abc-low = 'B'.
ls_abc-sign = 'I'.
ls_abc-option = 'EQ'.
append ls_abc to lr_abc.
ls_abc-low = 'C'.
ls_abc-sign = 'I'.
ls_abc-option = 'EQ'.
append ls_abc to lr_abc.
elseif P_B = 'X'.
ls_abc-low = 'D'.
ls_abc-sign = 'I'.
ls_abc-option = 'EQ'.
append ls_abc to lr_abc.
ls_abc-low = 'E'.
ls_abc-sign = 'I'.
ls_abc-option = 'EQ'.
append ls_abc to lr_abc.
ls_abc-low = 'F'.
ls_abc-sign = 'I'.
ls_abc-option = 'EQ'.
append ls_abc to lr_abc.
endif.
select * from xxx where abc in lt_abc.
2009 May 27 11:10 AM
Hi,
Use a select option in selection screen where you can pass your own varibale and do a select
SELECT * FROM tbl WHERE abc IN variable where variable = s_var(select option)
2009 May 27 11:15 AM
First , Decide values to be used in where clause on the basis of the parameter on selection screen.
Then, Use SELECT statement to fetch data.
2009 May 27 11:15 AM
Hi,
that is possible. only thing is that the variable should have the values in the same format as it appears in the where condition.
if p_a EQ 'X'
the select-statement should be:
SELECT * FROM tbl WHERE l_v_condition --> l_v_condition = abc IN 'a', 'b', 'c' - this complete value as a single string should be stored in the variable. u can use concatenate to get this....
else a range table can be created and based on the condition u can add values to the range and use it in the where condition
r_wa_where-low = 'a'.
r_wa_where-sign = 'I'.
r_wa_where-option = 'EQ'.
append r_wa_where to r_where.
r_wa_where-low = 'b'.
r_wa_where-sign = 'I'.
r_wa_where-option = 'EQ'.
append r_wa_where to r_where.
r_wa_where-low = 'c'.
r_wa_where-sign = 'I'.
r_wa_where-option = 'EQ'.
append r_wa_where to r_where.
if p_a EQ 'X'
the select-statement should be:
SELECT * FROM tbl WHERE abc IN s_where.
2009 May 27 11:31 AM
Hi,
you can first populate different ranges in the INITIALIZATION event, and based on the radio button that is selected, you can use that range in the select statement.
Incase you want to use only one variable (which can contain all the values) then what you will have to do is.
1. Create an internal table with two fields in it (Value, Condition).
2. Create a range or an internal table with all the entries that you want.
3. When you populate the internal table, give all the values in the Value Field and the Radio Button names in the Condition field and append it to the internal table. (Do this in the INITIALIZATION event).
4. Now do a LOOP at the Internal Table WHERE condition = 'RB_1' (Radio button name 1).
5. Inside the loop write the select statement. Endloop.
6. If you dont want the select to be inside the loop, write a select with for all entries in the Internal table.
Regards,
S.Dakshna Nagaratnam.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |