Ansicht
Dokumentation

ABENABAP_SQL_HOST_VARIABLES - ABAP SQL HOST VARIABLES

ABENABAP_SQL_HOST_VARIABLES - ABAP SQL HOST VARIABLES

SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.
SAP E-Book

- @dobj

... @dobj ...

Effect

Specifying a host variable in a statement. Host variables are global or local data objects dobj declared in the ABAP program that are used in operand positions of statements. Instead of the data object itself, a field symbol to which the data object is assigned can also be specified. Dereferenced data reference variables can also be specified. Depending on the operand position, the data objects can be variables or constants. Constant host variables are host constants.

To identify a host variable, the names of named data objects or field symbols should always be directly prefixed by the escape character @. The escape character can only be used in programs, in which the program property fixed point arithmetic is activated. When the escape character is used, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.

The content of host variables in read positions is passed to the database system together with the SQL statement before it is executed. The content of host variables in write positions is taken from the database system after the SQL statement is ended.

  • Read positions in which host variables are handled as elementary SQL expressions are subject to the corresponding rules and any mappings are made to a dictionary type. The content is evaluated on the database in accordance with this type.
  • In operand positions in which host variables are not handled as SQL expressions, a type conversion into the appropriate data type takes place if required. In read positions, it must be possible to convert the content of a host variable to the data type required in the operand position in a lossless manner. Any unsuitable host constants produce syntax warnings or syntax errors, depending on the syntax check mode. Host variables that cannot be converted in a lossless manner produce a catchable exception of class CX_SY_OPEN_SQL_DATA_ERROR.

Notes

  • In some operand positions in which host variables are allowed and host expressions are prohibited, a host variable can nevertheless be specified with the syntax @( dobj ) and is handled as a host variable and not as an expression.
  • ABAP data objects that are specified as enclosed dynamic tokens do not belong to the host variables and cannot be prefixed by the escape character @.
  • The escape character for host variables is independent of the general escape character for names !. The escape character ! can also be written in front of host variables that are already prefixed by the escape character @. However, this is not recommended.
  • Specifying host variables without the escape character @ is obsolete. The escape character @ must be specified in the strict modes of the syntax check from Release .
  • In addition to host variables, literals can also be specified at the respective read positions in statements. A literal, however, cannot and does not need to be prefixed by the escape character @. While untyped literals usually handled like host variables, typed literals are always handled as elementary SQL expressions.
  • If host variables are used as elementary SQL expressions, in particular as operands of other SQL expressions, they are mapped to a fixed dictionary type and the corresponding rules apply. This is different from their use in other operand positions, for which conversions to different dictionary types are generally possible.
  • When host variables with an escape character @ are specified, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.

Example

Specification of different host variables, whereby the escape character @ is always used.

Example

Use of a host variable prefix with the type c and a host variable name of the type string. The host variable name is used on the right-hand side of the WHERE condition. A string is possible, but not an SQL expression.

Example

The following SELECT statement raises an exception because the content of the host variable carrid cannot be assigned in a lossless manner. If carrid were a constant, there would be an additional syntax warning.






Fill RESBD Structure from EBP Component Structure   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 6512 Date: 20240419 Time: 102858     sap01-206 ( 112 ms )