To implement an Unmanaged Query in RAP, you follow a structured approach involving several key steps. First, you create a CDS view entity that defines the data structure or projection you want to expose. Then, you define a Query Behavior Definition for that view using the keyword define behavior for ... implementation in class ... unmanaged. This tells RAP that you will provide your own implementation logic rather than relying on managed data handling.
Next, you create an ABAP class (the query provider class) that implements the interface IF_RAP_QUERY_PROVIDER. The core method IF_RAP_QUERY_PROVIDER~SELECT must be redefined in this class. Inside this method, you write custom ABAP logic to retrieve data — it could be from a database table, an API, or even a legacy system. You then fill the result table and pass it back to the framework.
This unmanaged approach is used when data retrieval cannot be handled by CDS-based managed queries (for example, reading from custom logic, calling RFCs, or combining different data sources). It provides greater flexibility at the cost of additional coding responsibility.
Example structure:
CLASS zcl_query_provider DEFINITION
PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_rap_query_provider.
ENDCLASS.
CLASS zcl_query_provider IMPLEMENTATION.
METHOD if_rap_query_provider~select.
” Custom data retrieval logic
ENDMETHOD.
ENDCLASS.