The purpose of this blog is creating action in back-end using OData service v4 and call this action in sap analytics cloud and execution.
SAP Analytics Cloud supports OData services for importing data from different data sources like SAP HANA (after exposing the SAP HANA Views as a web service), SAP Cloud, SAP Business by Design for example. SAP Analytics Cloud supports OData Version 4.0 for actions.
Actions will provide a way to inject behaviors into an otherwise data centric model without confusing the data aspects of the model, while still staying true to the resource-oriented underpinnings of OData. These actions will be return in metadata when when OData service added in analytic application.
Need to create an application in SAP Gateway Service Builder (transaction SEGW) with the OData service version V4 and analytic application in sap analytics cloud.
- Go to SEGW and Create a project that contains the OData services and artifact.
- Create the data model by importing the DDIC Structures.
- Entity Sets represent collections of entities in the OData service.
- In preparation for exposing the OData service, generate runtime ABAP objects based on the data model, and generate corresponding model class implementations along with data provider shells.
- Expose the service on NetWeaver Gateway and conduct an initial test. The Service Maintenance function in the Service Builder enables you to register and maintain each service in an SAP NetWeaver Gateway system.
- A Data model can be anything : A table, A structure, A View.
- When we import a DDIC structure, its Entity Types, Entity Sets, Service Implementation, Runtime Artifacts are created automatically.
- A Data Model is the one that decides on which fields the CRUD operations will be performed
- DPC& DPC_EXT
- MPC & MPC_EXT
- The mentioned above are four classes generated by SAP. We only redefine methods of EXT classes, because the codes written in DPC and MPC are provided by SAP, and will override our codes once ODATA is generated.
- In DPC_EXT we perform CRUD operations
- IN MPC_EXT we write annotations
Annotations are the extra functionality we want to achieve that is not provided by SAP by default.
Model Provider class(MPC) registers the metadata used in a service, it is nothing but base class and model provider extension class is nothing but derived class.
MPC is used to define model you can use the method Define create entity and properties.
First we need to define the model and actions in model provider extension class.
In implementation of method define model we need to take structure to create entity in our model as per shown in below figure. And we are defining the Entity data model (EDM) name.
Next, we need to define actions and parameters which we are sending. The key fields in the data table are binding parameters we have to set entity type to key fields. For non-key fields we need to set primitive type as per shown in below figure.
Entity Type is our very own structure (or a work area (holds just one row)). And you guessed it right, Entity Set is an internal table (holds more than one entity/rows).
Data provider class provides the methods to Data provider Extension class, so developer can implement the functionalities for database interaction.
Open the class and implement the logic in execute action method. When we trigger the action, it executes this method. So, by taking the parameters from the action and we me implement the required action. Here requesting the key structure and data structure from service and updating that data into database table.
We can see the created action when we add an OData service in SAP Analytics cloud. When the metadata called its returns, the entity sets and actions which we defined in the back-end.
We can see the execute action method calling and parameters sending to the back-end OData service as shown in below figure.
Research:If you are interested go with SAP Analytics cloud crud operations.
Hope this blog will be useful to you.