This blog is about the workarounds for String functions in ABAP CDS Views and talks about the implementation using CDS Table and AMDP Functions.

ABAP CDS table function is defined in the type CDS DDL. In general, the CDS table is implemented using the AMDP method amdp_function, which is created using the AMDP framework in the database system as an AMDP function. This blog is a follow up blog from the previous one where we discussed string operations in HANA Models and workarounds to achieving the same.

A CDS table function returns data of type table and it is available in the namespace of the data types in the ABAP dictionary so this can be used as a data source in other CDS entities.

Process

Steps to create the CDS table function, ABAP class and consuming it in CDS view is explained below:

    1. Go to ABAP perspective and create a CDS table function by using the same approach as of CDS view. Specify the columns which are required as output of the table function.

ABAP-CDS-table-function-with-AMDP-function-implementation

2. To create AMDP methods select the ABAP class in as mentioned in the below image.

ABAP-CDS-table-function-with-AMDP-function-implementation

3. Provide proper naming standards and click on finish.

ABAP-CDS-table-function-with-AMDP-function-implementation

4. Kindly note that AMDP function implementation for a CDS table function can only be declared in the public visibility section of a static AMDP class. Use the below image example to create class for table function. Here we also include the logic to determine the Area Code within the ID Description.

<ABAP-CDS-table-function-with-AMDP-function-implementation

5. Consume the above created CDS Table Function in the CDS view to fetch Area code based on ID.

ABAP-CDS-table-function-with-AMDP-function-implementation

 

Below is the output for the CDS view with area codes(required_value)

ABAP-CDS-table-function-with-AMDP-function-implementation

Subscribe to our Newsletter

5600 Tennyson Pkwy
Suite 120
Plano TX 75024.

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192

solutions@visualbi.com