EXCEC SQL PERFORMING subr.
SELECT ... INTO :wa1 :wa2 ...
ENDEXEC.
If the PERFORMING addition that is forbidden in classes is specified after EXEC SQL, the native SQL interface performs an implicit cusor edit.
Only a SELECT statement can be used as a native SQL statement. The native SQL interface starts a cursor for the SELECT statement and reads the appropriate data, row by row. After each successful read of a row, the subr subroutine is called. The subr subroutine must be defined in the same ABAP program and must not have any parameter interface.
When the host variables specified in the
SELECT statement after INTO are global data
objects of the ABAP program, they can be evaluated in the subroutine. In the subroutine,
sy-dbcnt gets the number of rows read so far and sy-subrc
is set to the value 0. After the ENDEXEC statement,
sy-dbcnt contains the number of rows read altogether so far and sy-subrc is set to value 4 since no more lines could be read using the implicit cursor.
Implicit cursor processing using the PERFORMING addition
is not allowed in ABAP objects since methods of global classes do not have any access to the global data and the subroutines of the calling ABAP program. Instead,
explicit cursor processing should be used.
Reading several rows from the database table SCARR and calling the subroutine evaluate for each row read.
DATA wa TYPE spfli-carrid.
EXEC SQL PERFORMING evaluate.
SELECT carrid FROM spfli INTO :wa
ENDEXEC.
FORM evaluate.
WRITE / wa.
ENDFORM.