Dynamic SQL Query

Question:
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
Answer:
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.
Answer:
Also you can use ranges.
_________________
Best regards, Sergey Korolev
Answer:
hi, you can refer the SAP transaction ABAPDOCU , which has lots of example including dynamic selection.
pops

More Articles:

COPA Re-Init - How to/recomendations?
Scheduling Transactions?
ws_download?
What does ' Include <object > mean?
MIGO - account determination?
IMG tree?