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:
- 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.
- To create AMDP methods select the ABAP class in as mentioned in the below image.
- Provide proper naming standards and click on finish.
- 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.
- Consume the above created CDS Table Function in the CDS view to fetch Area code based on ID.
Below is the output for the CDS view with area codes(required_value)