cancel
Showing results for 
Search instead for 
Did you mean: 

How to bind Multi Model / OData Services in Fiori Project?

Former Member
0 Kudos

Hello SAPUI5 developers,

I try to extend an Fiori app "Approve Supplier Invoice" and want to bind an additional Odata service from the application "TrackPurchase Order".

"Approve Supplier Invoice"  MM_SUPPLINV_APV  is used odata service: MM_SUPPLIER_INVOICE_APPROVE

"TrackPurchase Order"       MM_PURORD_TPO    is used odata service: SRA020_PO_TRACKING


I want to use both odata services in one fiori project / extension project.


I have created a project in Ecplise with a structure


     appconfig (fiori sandbox)

     mm_supplinv_apv (main application) - shared with SAPUI5 ABAP Repository - MM_SUPPLIER_INVOICE_APPROVE

     zm_supplinv_apv (extended)

The binding for odata service and data model is placed in Configuration.js by mm_supplinv_apv application

jQuery.sap.declare("ui.s2p.mm.supplinvoice.approve.Configuration");

jQuery.sap.require("sap.ca.scfld.md.ConfigurationBase");

jQuery.sap.require("sap.ca.scfld.md.app.Application");

sap.ca.scfld.md.ConfigurationBase

  .extend( "ui.s2p.mm.supplinvoice.approve.Configuration",

  {

       oServiceParams : {

            serviceList : [ {

            name : "MM_SUPPLIER_INVOICE_APPROVE_Entities",

            masterCollection : "WorkflowItems",

            serviceUrl : "/mm_supplinv_apv/proxy/sap/opu/odata/sap/MM_SUPPLIER_INVOICE_APPROVE;mo/",

            isDefault : true,

            useBatch : false,

            mockedDataSource : "/ui.s2p.mm.supplinvoice.approve/model/metadata.xml"

            } ]

  },

       getServiceParams : function() {

       return this.oServiceParams

  },

       getServiceList : function() {

       return this.getServiceParams().serviceList

  },

       getMasterKeyAttributes : function() {

       return [ "Id" ]

  },

  });

The application zm_supplinv_apv has a Component.js where I have defined an extansion points.

I want use an additional odata service just in the extension application, where I whant to define a new screens.

How and where shoud I define or bind this new odata service SRA020_PO_TRACKING?

If I define it in Configuration.js by mm_supplinv_apv application, I get a frontend error during starting an app from fioriSandbox on the Tomcat server.

oServiceParams : {

            serviceList : [ {

            name : "MM_SUPPLIER_INVOICE_APPROVE_Entities",

            masterCollection : "WorkflowItems",

            serviceUrl : "/mm_supplinv_apv/proxy/sap/opu/odata/sap/MM_SUPPLIER_INVOICE_APPROVE;mo/",

            isDefault : true,

            useBatch : false,

            mockedDataSource : "/ui.s2p.mm.supplinvoice.approve/model/metadata.xml"

            } ,

                    {

            name : "SRA020_PO_TRACKING_SRV",

            masterCollection : "POLists",

            serviceUrl : "/mm_supplinv_apv/proxy/sap/opu/odata/sap/SRA020_PO_TRACKING_SRV;mo/",

            isDefault : true,

            mockedDataSource : "/ui.s2p.mm.purord.tracking/model/metadata.xml"

  }

]

  },

Odata service SRA020_PO_TRACKING is activated and the application MM_PURORD_TPO is running separately without errors.


The Projekt mm_supplinv_apv was shared with Odata Service MM_SUPPLIER_INVOICE_APPROVE hosted by ABAP Repository.

May be an additional odata service should be shared as well, but how?


I found as well the following blog

, however I don't have a big experience in java script and don't know where should I define this code in Fiori project.


Do you have any idea how to solve this problem?


Thanks in advance!

Regards,

Dmitry



Accepted Solutions (0)

Answers (2)

Answers (2)

RameshShrestha
Contributor
0 Kudos

Hi Dmitry,

You are using the extension for new screens then you will be defining the view extension, so in the view controller you can define new service and use it normally as you do else where. Just define the service and set model to the specific view or UI on which you need new service.

If you need to use both service value in same UI, then proceed the link that you have shared.

If this does not work then make read call to both odata serivce synchronously , then create JSON model and bind it. This should work.

With Regards,

Ramesh Shrestha

Former Member
0 Kudos

Hi Dmitry,

Did you find a sultion to the issue.Even i am working on an application where i need to extend an application and one of the value is from other odata service url.

Regards

Radhika