cancel
Showing results for 
Search instead for 
Did you mean: 

Reuse javascript files in different sapui5 applications

Former Member
0 Kudos

Hi,

Can someone tell me the best way to reuse javascript files in different sapui5 applications. Where is the best save these files/functions in my abap system.

Kind regards,

Richard Middelburg

Accepted Solutions (0)

Answers (1)

Answers (1)

vijay_kumar49
Active Contributor
0 Kudos

is it possible to save the JS files under ABAP System?

Former Member
0 Kudos

Hi,

Yes you can same javascript files in Abap system. If you develop an SAPUI5 app and you deploy this app on a ECC system. It will be saved as a BSP application incl. the javascripts.

Richard

jamie_cawley
Advisor
Advisor
0 Kudos

Yes some fiori apps use the same approach such as simple finance.  Just create a reuse library with the needed resources to share among your desired apps.

Regards,

Jamie

SAP - Technology RIG

Former Member
0 Kudos

Thanks Jamie,

Can you tell me what the needed resources are. Where do I save this library is my SAP system and how can I call this library in my application. I use mainly HCM apps and have no finance apps installed.

Regards,

Richard

former_member183518
Active Participant
0 Kudos

You can make use of jQuery.sap.registerModulePath method and access js file from other applications just similar to how you'd access within the same app.

JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - jQuery.sap

former_member182372
Active Contributor
0 Kudos

two things to add

sap.ui.component.load( {

  name : "xxx.hcm.mss.utils.Component",

  url : "/mss/util/"

});

and

jQuery.sap.registerResourcePath("xxx/hcm/mss/utils", "/mss/util/");

which technically the same thing as registerModulePath but with no "."->"/" conversion

jQuery.sap.registerModulePath = function registerModulePath(sModuleName, vUrlPrefix) {

  jQuery.sap.assert(!/\//.test(sModuleName), "module path must not contain a slash.");

  sModuleName = sModuleName.replace(/\./g, "/");

  // URL must not be empty

  vUrlPrefix = vUrlPrefix || '.';

  jQuery.sap.registerResourcePath(sModuleName, vUrlPrefix);

};

jamie_cawley
Advisor
Advisor
0 Kudos

The needed resources would be any file that you created and needed for you applications.  You would just deploy it into your gateway system the same way as any other app.

Regards,

Jamie

SAP - Technology RIG