Dynamic SQL Query
Hi All,
Can anyone tell is it possible to write a Dynamic SQL Query. My requirement is as follows :
I have to select a field from the table A909. But the WHERE clause changes based on certain criteria. For example, Sometimes the query would be
SELECT SINGLE KNUMH INTO A909-KNUMH FROM A909
WHERE KSCHL EQ 'V' AND
VKORGAU EQ 'SP01'.
and sometimes it would be
SELECT SINGLE KNUMH INTO A909-KNUMH FROM A909
WHERE KSCHL EQ 'V' AND
VKORGAU EQ 'SP01', AND
MATNR EQ '12345678910' AND
KBSTAT EQ SPACE.
Any help is highly appreciated.
Thanks in advance
Depending on the condition write the select in the if -- endif. That I think should solve your problem. It does not have to dynamically select from table I guess.
Kavitha.
Also you can use ranges.
_________________
Best regards, Sergey Korolev
hi, you can refer the SAP transaction ABAPDOCU , which has lots of example including dynamic selection.
pops