Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Operands and Expressions →  ABAP SQL - SQL Expressions sql_exp 

sql_exp - sql_string

Other versions: 7.31 | 7.40 | 7.54

Syntax


... sql_elem1 && sql_elem2  [&& sql_elem3 ... ] ...

Effect

String expression in ABAP SQL. The operator && chains the character strings in two adjacent operand to a single character string. Elementary SQL expressions can be specified as the operands sql_elem1, sql_elem2, with the following restrictions:

  • Host variables and host expressions must be of ABAP type c.

The result of the chaining must be no longer than 255 characters. Trailing blanks are handled as follows:

  • Precisely one blank is respected in host variables declared using CONSTANTS and in text field literals consisting only of blanks.
  • In all other cases, trailing blanks are cut off on the right.

The result has the type CHAR in the resulting length and can be assigned to the ABAP types c and string in accordance with the associated assignment rule.

If the operand of a string expression has the null value, the result of the full string expression is the null value.


Notes

  • Specifying a string expression always means specifying an SQL expression. String expressions can only be specified for operand positions for which SQL expressions are possible.

  • Strings can also be concatenated using the SQL function CONCAT. The function CONCAT is restricted to concatenations of two operands but has the following benefits when compared to the operator &&:

  • Any SQL expressions are permitted as operands.

  • It allows more data types.

  • It does not apply any special handling to constants and text field literals that contain only blanks.

  • It allows results to be longer than 255 characters.

Example

The two columns in a results set are created using a chaining of character-like columns of the data source and of literals.

SELECT FROM spfli 
         INNER JOIN scarr 
           ON spfli~carrid = scarr~carrid 
       FIELDS spfli~carrid && ' ' && '(' && scarr~carrname && ')' 
              AS carrier, 
              cityfrom && ' ' && '-' && ' ' && cityto 
              AS connection 
       ORDER BY spfli~carrid, connid 
       INTO TABLE @DATA(result). 

cl_demo_output=>display( result ).

Executable Example

SQL expressions, chainings

Continue

SQL Expressions, Chainings