String functions in general used to perform manipulation of string data. In ABAP CDS there are a variety of string functions to perform operation in the strings. These functions have certain limitations on how the operations can be done. The details are explained in the example below.

For this illustration, we have created a table named ZSTRINGDATA  to consume in CDS views. The table contains ID and ID_DESC fields as shown in the image below

String Functions in ABAP CDS Views


Below data is loaded into the table to illustrate the string operations capabilities in CDS views. Where Customer Denotes the sales person and description denotes the file they have shared which contains area codes denoting from “_” to “.”.

String Functions in ABAP CDS Views
String operations in ABAP CDS views contains variety of functions like CONCAT, LTRIM, RTRIM, LEFT, RIGHT, SUBSTRING etc., which can be used to manipulate the string values form the data. For more details on the string functions refer to the ABAP documentation link provided below:


In this blog we are going to discuss more about the string functions like LEFT(arg, len), RIGHT(arg,len), SUBSTRING(arg, pos, len)  where the length has been specified to fetch data.

In the below CDS view the functions left, right and substring provides data based on the length specified.

String Functions in ABAP CDS Views



String Functions in ABAP CDS Views


Let’s check the case where we need to fetch the area codes dynamically from description(ID_DESC) using the syntax <NAME>_<AREA_CODE>.<EXTN>form “_” to “.”.

The position of these are being calculated using the string function instr and this function provides integer as an output.

Instr(“ID_DESC”,’_’) to fetch the position of character “_”

Instr(“ID_DESC”,’.’) to fetch the position of character “.”

Ideally since the instr function provides integer data type as output it can be used in the string functions to fetch the data from a specific length.

When this function is used in other functions with length to be provided it shows error that only literals, possibly positive numbers must be used in the function. The details are provided in the image shown below.

Error message is shown in the below image:

String Functions in ABAP CDS Views


To resolve the above issue, we would have to approach the solution from other perspectives namely:

  1. Extended view based on HANA Views- View blog here
  2. ABAP CDS Table Function with AMDP Function Implementation- View blog here


Subscribe to our Newsletter

5600 Tennyson Pkwy
Suite 120
Plano TX 75024.

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192