Skip to Content
Author's profile photo Maksim Rashchynski

“Origin? Multiple!”: How to implement dynamic origin in Fiori applications

Many are aware of the nice feature of the SAP Gateway – Multi Origin:

Support of multiple backend systems – How to use Multi Origin Composition and Routing

And ability to dynamically calculate an alias

Dynamic System Alias Calculation Via /IWFND/ES_MGW_DEST_FINDER – SAP NetWeaver Gateway – SAP Library

But there is a way to control it from UI. In order to enable it from Fiori/UI side a special instruction should be appended to the OData service URL – “;o=<system_alias>” for specifi origin and “;mo” for multi origin support.

A lot of Fiori applications use metadata’s “” config property to specify a service configuration details. So, common practice is to cerate an extension component and redefine that property:

metadata : {
config: {
"" : [{
     serviceUrl: "<THE_OLD_URL>;mo/",//for multi origin

The major limitation here is that we have to hardcode origin (or multi origin flag) in the component’s code. So, why don’t we try to make it dynamic and driven by configuration property?

The most obvious place to implement it would be a component’s constructor (Sales Order Track application for example). Component’s metadata has method applySettings which extends component’s metadata with additional supplied object.

constructor: function(sId, mSettings) {
  try {
//trying to read parameters from component configuration
  if( sId && sId.componentData && sId.componentData.startupParameters && sId.componentData.startupParameters.Origin[0] )
       var serviceURL;
       var origin = sId.componentData.startupParameters.Origin[0];
       if( origin === "MULTI")
            serviceURL = "/sap/opu/odata/sap/SRA018_SO_TRACKING_SRV;mo/";
            serviceURL = "/sap/opu/odata/sap/SRA018_SO_TRACKING_SRV;o=" + origin + "/";
       this.getMetadata().applySettings( { metadata : {
            config: {
            "" : [{
                 name: "SRA018_SO_TRACKING_SRV",
                 masterCollection: "SalesOrders",
                 serviceUrl: URI(serviceURL).directory(),
                 isDefault: true,
                 countSupported: false,
                 useBatch: true,
  }, arguments);//calling parent's constructor to continue initialization
  } catch (e) {"An error occured while instantiating component: " + e);

But surprisingly it didn’t work and throws some non obvious exception. After some debugging we found out that applySettings expects a baseType property in metadata:

this.getMetadata().applySettings( { metadata : {
baseType : "",
config: {
"" : [{

And that little trick solved the problem.

So, now we can use extended Fiori application and specify an origin dynamically from component configuration: MULTI for multiple origin, and a name of the alias in case of particular origin.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Masayuki Sekihara
      Masayuki Sekihara

      This is a good example. I just got similar requirement from one of customers.

      Author's profile photo Maksim Rashchynski
      Maksim Rashchynski
      Blog Post Author

      Glad it is useful  Masa-san!

      Author's profile photo Bhagyashree Chopada
      Bhagyashree Chopada

      I have similar requirement and i was about to hard code System alias for same at UI level.

      I will give a try for this now.

      Author's profile photo Former Member
      Former Member

      Great content as usual Maksim!

      Author's profile photo Maksim Rashchynski
      Maksim Rashchynski
      Blog Post Author

      Thanks, Gavin!

      Author's profile photo Tejas Chouhan
      Tejas Chouhan
      Author's profile photo Alexander K
      Alexander K

      Hello Maksim.

      Can i get sap_origin without adding ";mo" to odata URL?