{"id":7953,"date":"2025-10-31T23:22:55","date_gmt":"2025-10-31T17:52:55","guid":{"rendered":"https:\/\/www.sapewmhelp.com\/?question=how-do-you-implement-an-unmanaged-query-in-rap-and-what-are-the-key-steps-involved"},"modified":"2025-10-31T23:22:55","modified_gmt":"2025-10-31T17:52:55","slug":"how-do-you-implement-an-unmanaged-query-in-rap-and-what-are-the-key-steps-involved","status":"publish","type":"question","link":"https:\/\/www.sapewmhelp.com\/?question=how-do-you-implement-an-unmanaged-query-in-rap-and-what-are-the-key-steps-involved","title":{"rendered":"How do you implement an Unmanaged Query in RAP, and what are the key steps involved?"},"content":{"rendered":"<p>To implement an <strong>Unmanaged Query<\/strong> in RAP, you follow a structured approach involving several key steps. First, you create a <strong>CDS view entity<\/strong> that defines the data structure or projection you want to expose. Then, you define a <strong>Query Behavior Definition<\/strong> for that view using the keyword <code>define behavior for ... implementation in class ... unmanaged<\/code>. This tells RAP that you will provide your own implementation logic rather than relying on managed data handling.<\/p>\n<p>Next, you create an <strong>ABAP class<\/strong> (the query provider class) that implements the interface <strong><code>IF_RAP_QUERY_PROVIDER<\/code><\/strong>. The core method <strong><code>IF_RAP_QUERY_PROVIDER~SELECT<\/code><\/strong> must be redefined in this class. Inside this method, you write custom ABAP logic to retrieve data \u2014 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.<\/p>\n<p>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.<\/p>\n<p>Example structure:<\/p>\n<p>CLASS zcl_query_provider DEFINITION<br \/>\nPUBLIC FINAL CREATE PUBLIC.<br \/>\nPUBLIC SECTION.<br \/>\nINTERFACES if_rap_query_provider.<br \/>\nENDCLASS.<\/p>\n<p>CLASS zcl_query_provider IMPLEMENTATION.<br \/>\nMETHOD if_rap_query_provider~select.<br \/>\n&#8221; Custom data retrieval logic<br \/>\nENDMETHOD.<br \/>\nENDCLASS.<\/p>\n<div class=\"text-base my-auto mx-auto pb-10 [--thread-content-margin:--spacing(4)] thread-sm:[--thread-content-margin:--spacing(6)] thread-lg:[--thread-content-margin:--spacing(16)] px-(--thread-content-margin)\">\n<div class=\"[--thread-content-max-width:40rem] thread-lg:[--thread-content-max-width:48rem] mx-auto max-w-(--thread-content-max-width) flex-1 group\/turn-messages focus-visible:outline-hidden relative flex w-full min-w-0 flex-col agent-turn\">\n<div class=\"flex max-w-full flex-col grow\">\n<div data-message-author-role=\"assistant\" data-message-id=\"249988b6-56ef-49de-986a-98a986eced09\" class=\"min-h-8 text-message relative flex w-full flex-col items-end gap-2 text-start break-words whitespace-normal [.text-message+&amp;]:mt-1\" data-message-model-slug=\"gpt-5\">\n<div class=\"flex w-full flex-col gap-1 empty:hidden first:pt-[1px]\">\n<div class=\"markdown prose dark:prose-invert w-full break-words dark markdown-new-styling\">\n<p>This allows you to control how data is fetched and presented to consumers while still leveraging the RAP framework for OData exposure and metadata management.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"z-0 flex min-h-[46px] justify-start\"><\/div>\n<div class=\"mt-3 w-full empty:hidden\">\n<div class=\"text-center\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div data-edge=\"true\" class=\"pointer-events-none h-px w-px\"><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","question-category":[175],"question_tags":[178,201,200,177,453],"class_list":["post-7953","question","type-question","status-publish","hentry","question-category-rap","question_tags-abap","question_tags-btp","question_tags-rap","question_tags-sap","question_tags-umanaged-query"],"_links":{"self":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question\/7953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question"}],"about":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7953"}],"wp:attachment":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7953"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion-category&post=7953"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion_tags&post=7953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}