SAP NetWeaver AS ABAP Release 750, ©Copyright 2016 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Dictionary → ABAP CDS in ABAP Dictionary → ABAP CDS - Data Definitions → ABAP CDS - DDL Statements → ABAP CDS - DEFINE VIEW → ABAP CDS - SELECT → ABAP CDS - SELECT, Predefined Functions → ABAP CDS - sql_functions →ABAP CDS - String Functions
The following table shows the potential SQL functions for strings in a CDS view in ABAP CDS, plus the requirements made on the arguments.. The meaning of the functions can be found under SQL Functions for Strings.
Function | Valid Argument Types | Result Type |
CONCAT(arg1, arg2) | See below | SSTRING if an argument has the type SSTRING, else CHAR with the length of the result. |
CONCAT_WITH_SPACE(arg1, arg2, spaces ) | arg1, arg2: see below spaces: positive numeric literal greater than 0 and less than or equal to 1331 |
SSTRING if an argument has the type SSTRING, else CHAR with the length of the result. |
INSTR(arg, sub) | arg: see below sub: non-empty numeric literal |
INT4 |
LEFT(arg, len) | arg: see below len: positive numeric literal greater than 0 and less than or equal to 1333 |
SSTRING if arg has the type SSTRING, else CHAR with length len |
LENGTH(arg) | See below | INT4 |
LPAD(arg, len, src) | arg: see below len: positive numeric literal greater than 0 and less than or equal to 1333 src: character Literal |
SSTRING if arg has the type SSTRING, else CHAR with length len |
LTRIM(arg, char) | arg: see below char: Character literal with length 1 |
SSTRING if arg has the type SSTRING, else CHAR with the length of arg. |
REPLACE(arg1, arg2, arg3) | See below | SSTRING if arg1 or arg3 has the type SSTRING, else CHAR with the maximum possible length of the result. |
RIGHT(arg,len) | arg: see below len: positive numeric literal greater than 0 and less than or equal to 1333 |
SSTRING if arg has the type SSTRING, else CHAR with length len |
RPAD(arg, len, src) | arg: see below len: positive numeric literal greater than 0 and less than or equal to 1333 src: character literal |
SSTRING if arg has the type SSTRING, else CHAR with length len |
RTRIM(arg, char) | arg: see below char: Character literal with length 1 |
SSTRING if arg has the type SSTRING, else CHAR with the length of arg. |
SUBSTRING(arg, pos, len) | arg: see below pos and len: positive numeric literal not equal to zero |
SSTRING, if arg has the type SSTRING, else CHAR or NUMC with a length of at least len |
The following can be specified as the arguments arg:
The valid argument types for arg, arg1, arg2, and arg3 are CHAR, CLNT, LANG, NUMC, CUKY, UNIT, DATS, TIMS, and SSTRING.
In functions where an explicit length len is specified, the actual length of the result is defined when the CDS view is activated and is at least as long as len.
In all functions with the exception of LPAD and RPAD, the trailing blanks of all arguments are removed before the actual processing and the trailing blanks of the result are removed before the return operation. In LPAD and RPAD, the trailing blanks of the argument src are preserved.
Note
The characters in the surrogate area of the system code page UTF-16 are handled as two characters by the CDS string functions. This must be respected when the length is determined and these characters must not be split by mistake.
Example
The following CDS view applies predefined SQL functions for strings in the SELECT list to columns of the database table DEMO_EXPRESSIONS. The program DEMO_CDS_SQL_FUNCTIONS_STRING uses SELECT to access the view.