Introduction
While working on an issue for a client who is on SAP S/4HANA 2021 Release, I came across an interesting challenge involving the DF34_RAW data type in an ABAP CDS view.
The requirement was to expose quantity values stored as DF34_RAW as standard decimal values. At first glance, this looked like a simple type conversion. However, the CDS view was consumed through Cloud Integration Data Services (CIDS) rather than OData, which introduced an important limitation.
In this blog, I’ll explain why this issue occurs, discuss the available solution options for different SAP S/4HANA releases, and share the approach that worked successfully in our project.
Business Scenario
A customer running SAP S/4HANA 2021 needed to expose quantity values stored as DF34_RAW through an ABAP CDS view. The CDS was consumed by Cloud Integration Data Services (CIDS), and the target application expected the values in Decimal format.
Data Flow (Downward):
SAP S/4HANA Database Table
↓
ABAP CDS View
↓
Cloud Integration Data Services (CIDS)
↓
Target system(IBP in our case) (Decimal Values)
Why Does This Issue Occur?
DF34_RAW is SAP’s internal storage format for DecFloat34 values. Since it is stored as a raw binary representation rather than a standard numeric type, ABAP CDS in SAP S/4HANA 2021 cannot directly interpret or cast it.
As a result, the field cannot be:
- Cast directly to a decimal type
- Used in arithmetic expressions
- Used in aggregation functions
- Used in filter conditions
Note: Native support for converting DF34_RAW was introduced in SAP S/4HANA 2022.

Problem Statement
While creating the CDS view, the activation failed with the following error:
CDS activation error: Non-supported data type in a condition
Example of failing CDS code:

Available Solution Options
Option 1 – SAP S/4HANA 2022 and Above (Recommended)
Starting with SAP S/4HANA 2022, ABAP CDS supports converting DF34_RAW by first casting it to abap.decfloat34 and then to the required decimal format.

Advantages
- Simple implementation
- Clean and readable CDS code
- No additional ABAP classes
- No AMDP required
- Database-level execution with excellent performance
Option 2 – SAP S/4HANA 2021 and Earlier
Approach 2.1 – Using Virtual Elements
Virtual Elements allow values to be calculated dynamically through an ABAP class.

The calculation logic is implemented using the IF_SADL_EXIT_CALC_ELEMENT_READ interface.
Advantages
- Easy to implement
- No database procedures required
- Works well with SAP Fiori applications
- Fully supported for OData services
Limitation
Virtual Elements are executed only during the OData runtime. Since CIDS reads the CDS data directly, the Virtual Element logic is never executed, resulting in empty or initial values.
Approach 2.2 – Using an AMDP Table Function (Recommended for CIDS)
For integration scenarios such as CIDS, the conversion must occur directly in the SAP HANA database.
The recommended approach is to use an ABAP Managed Database Procedure (AMDP) Table Function, which leverages SAP HANA’s native SQLScript conversion function:
abap_df34raw_to_decimal(assignment_qty)
Step 1 – Define the CDS Table Function

Step 2 – Implement the AMDP

Real time example:

Why AMDP?
- Conversion happens entirely inside SAP HANA before the data reaches CIDS
- Works perfectly with CIDS
- Avoids OData runtime dependencies
- Provides excellent performance
- Keeps conversion logic close to the data
Technical Comparison
| Scenario | Recommendation |
| SAP S/4HANA 2022+ | Use native CAST |
| SAP S/4HANA 2021 + Fiori/OData | Use Virtual Elements |
| SAP S/4HANA 2021 + CIDS | Use AMDP Table Function |
Key Learnings
- DF34_RAW is not supported directly in ABAP CDS expressions before SAP S/4HANA 2022.
- Native CAST support significantly simplifies development from SAP S/4HANA 2022 onwards.
- Virtual Elements are executed only within the OData runtime.
- Cloud Integration Data Services (CIDS) bypasses the OData layer, so Virtual Elements are not triggered.
- For SAP S/4HANA 2021 integration scenarios, AMDP Table Functions provide the most reliable and performant solution.
Conclusion
Although SAP S/4HANA 2022 introduces native support for converting DF34_RAW values within ABAP CDS, many customers continue to run SAP S/4HANA 2021 systems where this capability is not available.
In these landscapes, the appropriate solution depends on how the CDS view is consumed:
- Virtual Elements are well suited for SAP Fiori and OData-based applications
- AMDP Table Functions are the preferred approach for Cloud Integration Data Services (CIDS) and other extraction scenarios
Understanding these options helps developers choose the right implementation based on their system release and integration architecture, avoiding unnecessary troubleshooting and ensuring consistent data delivery.
References
- SAP Help Portal – ABAP CDS Views
- SAP Help Portal – ABAP Managed Database Procedures (AMDP)
- SAP Help Portal – CDS Virtual Elements
