SAP EXEC INTO ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• INTO EXEC SQL

ABAP_EXEC_SQL - INTO

ABAP_SYNTAX
EXEC SQL.
SELECT ... INTO [STRUCTURE] :host1 $[, host2$] ...
ENDEXEC.

What does it do?
In a native SELECT or FETCH statement specified between EXEC and ENDEXEC, an INTO clause can be specified to pass the read data to host variables host1 , host2, ... specified after the statement. If there are multiple rows in the result set, any one of the rows is read.
If a structure is specified as a host variable in after INTO, it is transformed by the Native SQL interface as if its components were listed as individual fields separated by commas. The addition STRUCTURE can be specified between INTO and a single host variable. This addition has the effect that the host variable is handled like a structure, even if an untyped formal parameter or an untyped field symbol is specified. Otherwise, when multiple values are being passed, depending on the platform, either the first value only is passed, or an exception is raised.



Latest notes:

The SAP-specific addition INTO is removed from the statement by the Native SQL interface before it is passed to the database.
The addition INTO can only be used in statements introduced using SELECT and FETCH. In a statement introduced using WITH to define a common table expression (CTE), for example, INTO is not possible. In cases like this, either OPEN or ADBC (recommended) must be used.
BEGIN_SECTION SAP_INTERNAL_HINT
With the hidden syntax lob you can denote the database type of a column LOB and switch on a LOB handling for transferring the data to a host variable.
END_SECTION SAP_INTERNAL_HINT
ABAP_HINT_END



Example ABAP Coding

As in the example for host variables. The addition STRUCTURE is specified after INTO. However, this is not necessary since wa is known statically as a structure. The structure wa is handled in the INTO clause as if all substrings were specified separately: INTO :wa-cityfrom, :wa-cityto .
ABEXA 00245
ABAP_EXAMPLE_END

Return to menu