Blogs / SAP / SAP BW/HANA / SAP HANA / String Functions in ABAP CDS Views – Known Limitations and Workarounds

String Functions in ABAP CDS Views – Known Limitations and Workarounds

Aug 9, 2018

SHARE

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 – Known Limitations and Workarounds

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 – Known Limitations and Workarounds

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:

https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abencds_f1_sql_functions_character.htm

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 – Known Limitations and Workarounds

Output:
String Functions in ABAP CDS Views – Known Limitations and Workarounds

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 – Known Limitations and Workarounds

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


Corporate HQ:
5920 Windhaven Pkwy, Plano, TX 75093

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192

solutions@visualbi.com


Copyright © Visual BI Solutions Inc.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Share This!

Share this with your friends and colleagues!