
Why Use CDS and OData for Lookups?
The combination of CDS and OData provides flexibility, scalability, and easy integration, which is critical for modern web-based lookup services.
Step 1: Create database table and Define the CDS View for Product Lookup
The first step is to Create database table and define a CDS view that will serve as the basis for our lookup service. The CDS view will fetch relevant fields from the product master data and allow filtering using input parameters.
Step 2: Activate and Expose the OData Service
Once the CDS view is created, the next step is to activate the OData service.
Steps to Activate the OData Service:
Once activated, you can now consume this OData service in any client to perform product lookups.
@AbapCatalog.sqlViewName: 'ZNA_VALUE'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'lookup service for Product table'
@Metadata.ignorePropagatedAnnotations: true
define view zna_value_help as select from zna_t_product
{
@Consumption.valueHelpDefinition: [{ entity: {element: 'Id',name: 'ZNA_T_PRODUCT' } }]
key id as Id,
@Consumption.valueHelpDefinition: [{ entity: {element: 'Name',name: 'ZNA_T_PRODUCT' } }]
name as Name,
@Consumption.valueHelpDefinition: [{ entity: {element: 'Category',name: 'ZNA_T_PRODUCT' } }]
category as Category,
@Consumption.valueHelpDefinition: [{ entity: {element: 'Price',name: 'ZNA_T_PRODUCT' } }]
price as Price
}
Here in Data model, Choose Reference--> Data Source and Provide CDS Entity name.
Here we can Observe that CDS Entity is Added here.
Here Just we have to Select Entity set and Perform Get Operation then Click On Execute.
Here we can See the Data.
Conclusion
In this blog post, we’ve walked through how to create a lookup service for product details using CDS and OData. This service allows applications to dynamically query product information based on user input, making it highly flexible and interactive.
By combining CDS views with OData, you can easily expose SAP data for external consumption while benefiting from the performance and flexibility of SAP HANA. Whether you’re building an SAP application or integrating with external systems, this approach ensures a smooth and efficient lookup experience.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 |