‎2008 Mar 10 9:44 AM
Hi friends,
I want to know how to use the EXEC SQL , EXECUTE statements in SAP.
Does the following steps possible with the EXEC SQL or EXECUTE statement.
I will declare a variable var1,var2,var3 of type Char with length 250.
var1 contains the following string:
" select f1 f2 f3 from table table1 into it_table where"
var2 contains the following string:
" f1 EQ XYZ."
var3 contains the combination of var1 and var2.
Now I want to execute var3 ( which contains a select statement).
Is that possible to execute that variable using EXEC SQL or EXECUTE. or is there any other way to handle this type of scenarios?If it is so could anyone help me with some example.
If it works, it will help me to handle performance issue.
Thanks in advance.
Regards,
Swarna Munukoti.
‎2008 Mar 10 9:54 AM
HI,
DATA: F1(3), F2(3), F3(3).
F3 = ' 1 '.
EXEC SQL.
SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
WHERE ARG2 = :F3
ENDEXEC.
WRITE: / F1, F2.
THANKS,
REWARD IF USEFUL.
ARUNPRASAD.P
‎2008 Mar 10 9:54 AM
HI,
DATA: F1(3), F2(3), F3(3).
F3 = ' 1 '.
EXEC SQL.
SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
WHERE ARG2 = :F3
ENDEXEC.
WRITE: / F1, F2.
THANKS,
REWARD IF USEFUL.
ARUNPRASAD.P
‎2008 Mar 10 10:23 AM
Hi ,
Thanks for reply. But my doubt is whether it is possible to execute the select statement dynamically.
What I mean to say is for example consider
var3 also contains another where condition like
" and f2 EQ 'ABC'. "
var4 contains a combination of var1, var2, var3.
var5 contains a combination of var1,var2.
I want to execute either var4 or var5 based on some condition.
Is there any way to do that ?
Thanks & Regards,
Swarna Munukoti.