Manual RAP action call in Fiori elements app using OdataV2.

Usage: This is particularly useful when working with RAP based service with manual implementation of actions in Fiori elements app.

manual RAP action call:

We can use invokeaction method of extension API in Fiori elements template or using callfunction method on odatamodel.

Call function example:

              I am using the standard attachment service /sap/opu/odata/sap/CV_ATTACHMENT_SRV to read the attachment of a particular business object.

Here GetAllOriginals is the entityset we are calling to retrieve data of Service Notification BO BUS2080

oDataModel.callFunction(“/GetAllOriginals”, {
method: “GET”,
urlParameters: {
“ObjectKey”: <NotificationNumber>
“ObjectType”: “BUS2080”,
“SemanticObjectType”: “”,
“IsDraft”: true,
“AttachmentFramework”: “”
},
success: function (oData, response) {
// perform further manipulation based on data
},
error: function (oError) {
//Error handling
});

Invokeaction example:

Here a Promise call is made on extension API using invoke action method.

<Actionname> à this is the action created in behaviour definition of RAP service. ( you can find this in metadata of service).

This action contains 3 properties to pass to backend. While calling invoke action we must pass keys of main entity(i.e main cds view entity of the app- these actually becomes key fields while creating the action).

var oPromise = this.extensionAPI.invokeActions(“/<Actionname>”,this.getView().getBindingContext(),{
“SalesOrd”:<salesorder>,
“SoItem”:<so item>,
“type” : <type>
});
oPromise.then(
function (aResponse) {
// perform further manipulation based on data
},
function (oError) {
//Error handling
});

If you have any questions, please feel free to drop a comment below. I will be happy to answer them.

Thanks,
Chandra.

 

​ Usage: This is particularly useful when working with RAP based service with manual implementation of actions in Fiori elements app.manual RAP action call: We can use invokeaction method of extension API in Fiori elements template or using callfunction method on odatamodel.Call function example:              I am using the standard attachment service /sap/opu/odata/sap/CV_ATTACHMENT_SRV to read the attachment of a particular business object.Here GetAllOriginals is the entityset we are calling to retrieve data of Service Notification BO BUS2080 oDataModel.callFunction(“/GetAllOriginals”, {
method: “GET”,
urlParameters: {
“ObjectKey”: <NotificationNumber>
“ObjectType”: “BUS2080”,
“SemanticObjectType”: “”,
“IsDraft”: true,
“AttachmentFramework”: “”
},
success: function (oData, response) {
// perform further manipulation based on data
},
error: function (oError) {
//Error handling
});Invokeaction example: Here a Promise call is made on extension API using invoke action method.<Actionname> à this is the action created in behaviour definition of RAP service. ( you can find this in metadata of service).This action contains 3 properties to pass to backend. While calling invoke action we must pass keys of main entity(i.e main cds view entity of the app- these actually becomes key fields while creating the action). var oPromise = this.extensionAPI.invokeActions(“/<Actionname>”,this.getView().getBindingContext(),{
“SalesOrd”:<salesorder>,
“SoItem”:<so item>,
“type” : <type>
});
oPromise.then(
function (aResponse) {
// perform further manipulation based on data
},
function (oError) {
//Error handling
});If you have any questions, please feel free to drop a comment below. I will be happy to answer them.Thanks,Chandra.   Read More Technology Blogs by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author