2009 Jun 22 12:53 PM
Hello,
I created a report in which i have two checkboxes in the selection screen. The first checkbox is for the option to bring or not, initial purchase requisitions (BANFN) from EKPO and the second is to bring initial or not, RFQs
(ANFNR). I want the select statment to have this form:
select ...
from ekpo
into g_table
where ..
and dynamic field = " ".
Can this be done ?
i tried to put it as a string but it didnt work. (data: dynamic field type string value "EKPO-BANFN")
P.S i know that it can be by writing the same select code twice.
I just wonder if this can be done by this way
\Regards.
2009 Jun 22 1:10 PM
Hey Nick,
I have more conditions than the one i said before , should all be in the lv_where_clause ?
check my code.
*************************************
DATA: G_CHBFLD type STRING.
G_CHBFLD = 'P~BANFN = '' " '.
FORM SELECT_DATA_EKPO_EKKO.
SELECT .....
FROM EKPO AS P INNER JOIN EKKO AS K
ON PEBELN = KEBELN
INTO CORRESPONDING FIELDS OF TABLE GT_EKPOEKKO
WHERE K~EBELN IN S_EBELN
AND K~AEDAT IN S_AEDAT
AND K~BSTYP IN S_BSTYP
and ( G_CHBFLD ) . -
> //DEBUGER ")" is not a valid comparison operator. comparison operator.
2009 Jun 22 12:57 PM
Hi,
You can have a dynamic where clause for your select statement.
Do F1 on SELECT and see the documentation under "WHERE - (cond_syntax)"
Regards,
Ankur Parab
2009 Jun 22 12:59 PM
Hi,
You can create the WHERE clause a a variable and construct it based on the selection criteria.
So your statement becomes;
select ...
from ekpo
into g_table
WHERE (lv_where_clause).
The variable lv_where_clause contains "FIELD1 = v_1 AND FIELD2 = v_2" etc.
Regards,
Nick
2009 Jun 22 1:00 PM
2009 Jun 22 1:10 PM
Hey Nick,
I have more conditions than the one i said before , should all be in the lv_where_clause ?
check my code.
*************************************
DATA: G_CHBFLD type STRING.
G_CHBFLD = 'P~BANFN = '' " '.
FORM SELECT_DATA_EKPO_EKKO.
SELECT .....
FROM EKPO AS P INNER JOIN EKKO AS K
ON PEBELN = KEBELN
INTO CORRESPONDING FIELDS OF TABLE GT_EKPOEKKO
WHERE K~EBELN IN S_EBELN
AND K~AEDAT IN S_AEDAT
AND K~BSTYP IN S_BSTYP
and ( G_CHBFLD ) . -
> //DEBUGER ")" is not a valid comparison operator. comparison operator.
2009 Jun 22 1:20 PM
Hi,
Try putting the whole WHERE clause in the variable,
G_CHBFLD = 'KEBELN IN S_EBELN AND KAEDAT IN S_AEDAT
AND KBSTYP IN S_BSTYPP AND 'PBANFN = '' " '.
........
FROM EKPO AS P INNER JOIN EKKO AS K
ON PEBELN = KEBELN
INTO CORRESPONDING FIELDS OF TABLE GT_EKPOEKKO
WHERE (G_CHBFLD) .
Regards,
Nick
2009 Jun 22 1:34 PM
WORKS for the debbuger, but it occurs a runtime error.
**************************
An exception occurred. This exception is dealt with in more detail below
. The exception, which is assigned to the class 'CX_SY_DYNAMIC_OSQL_SYNTAX',
was neither
caught nor passed along using a RAISING clause, in the procedure
"SELECT_DATA_EKPO_EKKO" "(FORM)"
.
Since the caller of the procedure could not have expected this exception
to occur, the running program was terminated.
The reason for the exception is:
The current ABAP program attempted to execute an Open SQL
statement containing a WHERE condition of the form WHERE (itab) or
WHERE ... AND (itab). The part of the WHERE condition specified at
runtime in the internal table itab contains a literal
"'" that begins with "'", but has no closing "'".
2009 Jun 22 1:38 PM
Hi,
Check your dynamic where clause.
Maybe you have not closed the literals with proper quotes.
Regards,
Ankur Parab
2009 Jun 22 1:40 PM
Hello,
Check if this works:
G_CHBFLD = 'K~EBELN IN S_EBELN AND K~AEDAT IN S_AEDAT
AND K~BSTYP IN S_BSTYPP AND P~BANFN = space'.BR,
Suhas
2009 Jun 22 1:48 PM