10-31-2008 12:25 PM
I have to pass select option in dynamic where clause(i_where) of a select query in 4.6c as follows.
SELECT kschl
FROM <Database table>
INTO TABLE ITAB
WHERE (i_where).
In the program, i_where is getting populated as below
WHERE MATNR IN S_MATNR and
VKORG IN S_VKORG.
But its giving short dump in select query, If I hard code the select option values, it is working fine. How to pass selection options in dynamic where clause as required above.
Thanks in Advance for your help!!!
10-31-2008 12:32 PM
10-31-2008 12:33 PM
Hello,
Better use the filed symbol before passing it to select statement just assign the select-option to field symbol then pass the field symbol to select statement.
10-31-2008 12:36 PM
Here :
Fill the where clause table
w_clause = ' f~bukrs = p_bukrs'.
APPEND w_clause TO i_clause.
w_clause = ' AND bstat = c_space'.
APPEND w_clause TO i_clause.
w_clause = ' AND f~budat IN so_budat'.
APPEND w_clause TO i_clause.
w_clause = ' AND f~belnr IN so_belnr'.
APPEND w_clause TO i_clause.
w_clause = ' AND f~gjahr IN r_year'.
APPEND w_clause TO i_clause.
w_clause = ' AND f~blart IN so_blart'.
APPEND w_clause TO i_clause.
w_clause = ' AND k~auart IN so_auart'.
APPEND w_clause TO i_clause.
select * from (tabname) into itab
WHERE (i_clause).
forgot to mention :
declare the i_clause table like this :
TYPES : line(50) TYPE c.
DATA : i_clause TYPE STANDARD TABLE OF line,
w_clause LIKE LINE OF i_clause.
regards,
Advait
Edited by: Advait Gode on Oct 31, 2008 1:41 PM
11-04-2008 3:54 PM
Thanks for the inputs. I tried but still getting dump in the select query. My code is perfectly working in 4.7 and ECC versions. Is there any problem with 4.6C with dynamic where clause selections?
11-04-2008 4:06 PM
08-24-2011 4:35 PM
Version 4.6C.....
Use Function Module RH_DYNAMIC_WHERE_BUILD
It will look like this...... MATNR IN ('1023222', '1045637')
08-24-2011 8:39 PM
SELECT kschl
FROM <Database table>
INTO TABLE ITAB
WHERE (i_where).
In the program, i_where is getting populated as below
WHERE MATNR IN S_MATNR and
VKORG IN S_VKORG.
Did you mean to say:
In the program, i_where is getting populated as below
MATNR IN S_MATNR and
VKORG IN S_VKORG
Or do you actually have two instances of "where"?
08-25-2011 8:42 AM
Hi Srinivasa,
try this -
concatenate 'MATNR' 'IN' 'S_MATNR' 'AND' 'VKORG' 'IN' 'S_VKORG' into i_where separated by space.
SELECT kschl
FROM <Database table>
INTO TABLE ITAB
WHERE (i_where).
Regards,
Kamini
08-25-2011 8:44 AM
Hi Srinivasa,
try this -
concatenate 'MATNR' 'IN' 'S_MATNR' 'AND' 'VKORG' 'IN' 'S_VKORG' into i_where separated by space.
SELECT kschl
FROM <Database table>
INTO TABLE ITAB
WHERE (i_where).
Regards,
Kamini
08-25-2011 8:44 AM
Hi Srinivasa,
try this -
concatenate 'MATNR' 'IN' 'S_MATNR' 'AND' 'VKORG' 'IN' 'S_VKORG' into i_where separated by space.
SELECT kschl
FROM <Database table>
INTO TABLE ITAB
WHERE (i_where).
Regards,
Kamini
08-25-2011 8:44 AM
Hi Srinivasa,
try this -
concatenate 'MATNR' 'IN' 'S_MATNR' 'AND' 'VKORG' 'IN' 'S_VKORG' into i_where separated by space.
SELECT kschl
FROM <Database table>
INTO TABLE ITAB
WHERE (i_where).
Regards,
Kamini
08-25-2011 8:46 AM
Hi Srinivasa,
try this -
concatenate 'MATNR' 'IN' 'S_MATNR' 'AND' 'VKORG' 'IN' 'S_VKORG' into i_where separated by space.
SELECT kschl
FROM <Database table>
INTO TABLE ITAB
WHERE (i_where).
Regards,
Kamini
08-25-2011 8:58 AM
TABLES: vbak.
DATA: condition TYPE string.
DATA: BEGIN OF itab OCCURS 0,
vbeln LIKE vbak-vbeln,
posnr LIKE vbap-posnr,
END OF itab.
DATA: it_options TYPE rfc_db_opt OCCURS 0 WITH HEADER LINE.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
CONCATENATE 'VBELN' 'IN' 'S_VBELN' INTO condition SEPARATED BY space.
it_options-text = condition.
APPEND it_options.
CLEAR it_options.
SELECT vbeln
posnr
FROM vbap
INTO TABLE itab
WHERE (it_options).
LOOP AT itab.
WRITE 'THANKS TO RICH/VIJAY'.
ENDLOOP.
...
08-25-2011 9:19 AM
be careful with spaces and dots
also maybe you have another 'where' in your clause