2008 Oct 08 11:02 AM
Hi Friends,
Is there any Function Module or Method for converting "Select-Options" table to SQL statment?
For example:
Coding: SELECT-OPTIONS s_tbnm FOR lv_table_name.
User enter on:
I need to convert selection option "s_tbnm" into a string
2008 Oct 08 11:05 AM
Not that i know of, but i'm curious: why should you want to do that? And what do you exactly want in that string?
2008 Oct 08 11:14 AM
There is a example.
Report coding:
SELECT-OPTIONS s_number FOR lv_number.
User enter on screen: 1 1000
I need to convert selection option "s_number" into a string which is "FROM 1 TO 1000".
Because I am calling function module
CALL FUNCTION 'RFC_READ_TABLE'
EXPORTING
query_table =
* DELIMITER = ' '
* NO_DATA = ' '
* ROWSKIPS = 0
* ROWCOUNT = 0
tables
OPTIONS =
fields =
data =
* EXCEPTIONS
* TABLE_NOT_AVAILABLE = 1
* TABLE_WITHOUT_DATA = 2
* OPTION_NOT_VALID = 3
* FIELD_NOT_VALID = 4
* NOT_AUTHORIZED = 5
* DATA_BUFFER_EXCEEDED = 6
* OTHERS = 7
.
The parameter OPTIONS is just a string, and its content is the "where" statement. So I have to convert selection option table into "where" statement.
Regarding to select-option is complicated, so I would like to find some library Funtion Module to resolve this.
So folks, any idea about this?
Thanks so much.
Edited by: Jiran Ding on Oct 8, 2008 12:14 PM
Edited by: Jiran Ding on Oct 8, 2008 12:14 PM
Edited by: Jiran Ding on Oct 8, 2008 12:15 PM
Edited by: Jiran Ding on Oct 8, 2008 12:16 PM
Edited by: Jiran Ding on Oct 8, 2008 12:16 PM
2008 Oct 08 11:22 AM
relop = ''.
loop at s_num.
concatenate relop ` FROM ` s_num-low ` TO ` snum-hi
into where_clause in character mode.
relop = ` OR `.
endloop.
Note the back quotes around the strings, they are not apostrophes and therefor blanks will be concatenated as well, using apostrophes will not deliver a correct where clause.
2008 Oct 08 11:22 AM
Never used the function, but when i did a where-used on the function i found a few usages that explained me how to use the function. And guess what? You could have done the same.
Anyhow, OPTIONS is a table in which you enter your WHERE clause.
In your example: 'fieldname IN s_number' or something like that.
2008 Oct 08 11:28 AM
Referring to your case, I suggest using range field to enter the "From" and "To" values separately instead of using one selection field only at the selection screen. This can reduce the chance of having error.