SAP OO OBS EXEC SQL 1

Get Example source ABAP code based on a different SAP table
  


ABAP Code Snippet
ARTICLE

Subroutine Calls Not Allowed in EXEC SQL
Using the PERFORMING addition in the EXEC SQL statement to use a subroutine to process data line by line that you have read using Native SQL is not allowed in ABAP Objects. The EXIT FROM SQL statement, previously used within such subroutines, is also forbidden.

In ABAP Objects, the following syntax causes an error message:

EXEC SQL PERFORMING form.
select ... into :wa from dbtab where ...
ENDEXEC.

FORM form.
...
EXIT FROM SQL.
...
ENDFORM.
Correct syntax:

EXEC SQL.
open c1 for
select ... from dbtab where ...
ENDEXEC.

DO.
EXEC SQL.
fetch next c1 into :wa
ENDEXEC.
IF sy-subrc <> 0.
EXIT.
ENDIF.
...
ENDDO.

EXEC SQL.
close c1
ENDEXEC.
Reason:

You should not call subroutines of the main program in local classes and you cannot call them in them from global classes. The called subroutine has no interface, working instead with the global data of the main program. The EXIT FROM SQL statement ends the SQL processing without reference to the actual SQL statement.