Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using EXEC SQL or EXECUTE statements

former_member217544
Active Contributor
0 Likes
538

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
472

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

2 REPLIES 2
Read only

Former Member
0 Likes
473

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

Read only

0 Likes
472

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.