Application Development 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: 

How to convert "SELECT-OPTIONS" table to SQL statement

Former Member
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

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?

Former Member
0 Kudos

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

0 Kudos

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.

0 Kudos

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.

0 Kudos

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.