2007 Dec 04 10:34 AM
Hi
I'm trying for a dynamic query and in the dynamic where clause i'm checking a field for constant.....for instance if i wanna to use WERKS EQ '0478' how to declare it in dync where clause. i tried for the following:
SELECT (TAB_FIELD) INTO TABLE DITAB UP TO 10 ROWS FROM (TAB_NAME) WHERE (CONDI).
heree CONDI = 'werks eq 0287' . in this case the query fails as the werks shud be equal to '0287' and not just 0287. How to handle this? i tried for the following
CONDI = 'werks eq " '0287' " ' but no luck as it is not a valid stmt as i knew.
2007 Dec 04 10:42 AM
hi Prabhu,
do:
condi = 'werks EQ ''0287'''.
double ' before 0287 and triple ' after 0287
ec
Hi
I'm trying for a dynamic query and in the dynamic where clause i'm checking a field for constant.....for instance if i wanna to use WERKS EQ '0478' how to declare it in dync where clause. i tried for the following:
SELECT (TAB_FIELD) INTO TABLE DITAB UP TO 10 ROWS FROM (TAB_NAME) WHERE (CONDI).
heree CONDI = 'werks eq 0287' . in this case the query fails as the werks shud be equal to '0287' and not just 0287. How to handle this? i tried for the following
CONDI = 'werks eq " '0287' " ' but no luck as it is not a valid stmt as i knew.
2007 Dec 04 10:38 AM
Hi,
SELECT (TAB_FIELD) INTO TABLE DITAB UP TO 10 ROWS FROM (TAB_NAME) WHERE werks eq '0287'.
Regards,
Prashant
2007 Dec 04 10:44 AM
dear prashant
i'm totaly aware of how to write a where clause but my question is how to use it in dynamic where clause.
2007 Dec 04 10:39 AM
concatenate text-001 '0287' text-001 into condi.
concatenate 'WERKS = ' l_value into condi separated by space.
set text-001 to '
Albert
2007 Dec 04 10:42 AM
hi Prabhu,
do:
condi = 'werks EQ ''0287'''.
double ' before 0287 and triple ' after 0287
ec
2007 Dec 04 10:46 AM
hi prabhu,
this is how u select dynamically...
DATA: COND(72) TYPE C,
ITAB LIKE TABLE OF COND.
PARAMETERS: CITY1(10) TYPE C, CITY2(10) TYPE C.
DATA WA TYPE SPFLI-CITYFROM.
CONCATENATE 'CITYFROM = ''' CITY1 '''' INTO COND.
APPEND COND TO ITAB.
CONCATENATE 'OR CITYFROM = ''' CITY2 '''' INTO COND.
APPEND COND TO ITAB.
CONCATENATE 'OR CITYFROM = ''' 'BERLIN' '''' INTO COND.
APPEND COND TO ITAB.
LOOP AT ITAB INTO COND.
WRITE COND.
ENDLOOP.
SKIP.
SELECT CITYFROM
INTO WA
FROM SPFLI
WHERE (ITAB).
WRITE / WA.
ENDSELECT.
regards,
sohi
2007 Dec 04 10:47 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |