✅ Overview: Custom Query as Service
You can use the following main approaches:
1. Create a CDS View (Core Data Services)
Create a CDS view with your custom logic (e.g., filtering, joining, aggregation) and annotate
it to expose as an OData service.
Key Steps:
Create a CDS view (e.g., ZMY_QUERY_VIEW) using Eclipse (ADT).
Annotate with OData exposure:
abap
Copy code
@OData.publish: true
define view ZMY_QUERY_VIEW as select from ...
Register OData service via /IWFND/MAINT_SERVICE (SAP Gateway).
Consume this service in any Fiori app using the exposed entity set.
Use Case:
Build a query on top of warehouse task and bin tables.
Provide a filtered dataset for a Fiori dashboard or analytical report.
2. Use Custom Analytical Queries (via Fiori App “Custom Analytical Queries”)
Steps:
Open app: "Custom Analytical Queries" (App ID: F1602).
Create a custom query based on a custom or standard analytical CDS view.
Publish this as a reusable analytical OData service.
Bind the resulting OData service to any Fiori app (e.g. via KPI modeler, Smart Chart).
Pros:
No coding.
Fully metadata-driven.
Ideal for analytics scenarios.
Prerequisites:
The base view must be analytical (@Analytics.query: true, @VDM.viewType:
#CONSUMPTION).
3. Build an ABAP RESTful Application Programming Model (RAP) Service
For more advanced needs, you can:
Create a RAP-based service (managed or unmanaged).
Define data model, projection, behavior, and service definition.
Use service binding to publish it as an OData service.
Use Case:
When you need validation, draft behavior, or transactional capabilities along with the query.
🧰 Tooling Requirements
Tool Purpose
Eclipse with ADT Create CDS views, annotations
SAP Gateway (/IWFND/MAINT_SERVICE) Activate & maintain OData services
Fiori App Library / Fiori Elements Bind custom service to app
SAP Business Application Studio or Web IDE Build UI with bound service
💡 Example: Exposing Custom Warehouse Task Query
CDS View:
abap
Copy code
@AbapCatalog.sqlViewName: 'ZWH_TASK_QRY'
@OData.publish: true
define view ZWH_TASK_QUERY as select from /SCWM/WME
association [1..1] to /SCWM/LAGP as _StorageBin on ...
{
key /SCWM/WME.LGNUM,
/SCWM/WME.TANUM,
/SCWM/WME.LGTYP,
_StorageBin.LGPLA
}
Register the OData in Gateway.
Use this query in another Fiori Elements app using Smart Table or Smart Chart.
✅ Final Summary
Task Approach
Custom data query (joins, filters) CDS view with OData annotation
Analytics for KPIs/dashboards Custom Analytical Query (App F1602)
Full transactional behavior RAP model (ABAP RESTful Programming)
UI Consumption Smart controls / UI5 or Elements
If you tell me the kind of data or app you're planning to use it in, I can suggest the best
path—CDS vs RAP vs Analytical Query—and guide you step by step.
Tools
ChatGPT can make mistakes. Check important info. See Cookie Preferences.