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

Dereferencing in Native SQL

Former Member
0 Likes
749

I am trying to run a SQL command built from a variable, and I am receiving an error. Is what I am trying to do not possible?

Here is an example:


EXEC SQL.
   :l_statement
ENDEXEC.

l_statement contains a valid Oracle statement.

Thanks for any help.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
724

Interesting, not sure if you can to Native SQL dynamically or not. I know that you woud probably be able to generate a subroutine with the code in it.

Regards,

Rich Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
725

Interesting, not sure if you can to Native SQL dynamically or not. I know that you woud probably be able to generate a subroutine with the code in it.

Regards,

Rich Heilman

Read only

0 Likes
724

Here is an example. Just put your statement in the variable.



report   zrich_0001  .


types: t_source(72).

data: routine(32) value 'TEMP_ROUTINE',
            program(8),
            message(128),
            line type i.
data: l_statement(50) type c value 'What Ever'.
data: isource type table of t_source,
            xsource type t_source.



xsource = 'REPORT ZTEMP_REPORT.'.
insert xsource  into isource index 1.
xsource = 'FORM &.'.
replace '&' with routine into xsource.
insert xsource  into isource index 2.


xsource = 'EXEC SQL.'.
append xsource to isource.
xsource = l_statement.
append xsource to isource.
xsource = 'ENDEXEC.'.
append xsource to isource.


xsource = 'ENDFORM.'.
append xsource to isource.

generate subroutine pool isource name program
                         message message
                         line line.
if sy-subrc = 0.
  perform (routine) in program (program).
else.
  write:/ message.
endif.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
724
EXEC SQL. 
  SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT 
         WHERE ARG2 = :F3 
ENDEXEC.

what kind of error you are getting....

Read only

Former Member
0 Likes
724

Subroutine Calls Not Allowed in an ABAP Objects context.

if you are using in OO it won't work....

EXEC SQL.
   :l_statement
ENDEXEC.

will fail...