Skip to Content

Code reuse in on premise sapui5 apps

Hi all,

I've been searching and reading info about re-using coding in a SAPUI5 app, but I cannot seem to find an official recommendation for my use-case.

The use-case: I have a .js file, lets say a SomeUtilFunction.js, that I want to use in multiple SAPUI5 applications deployed in an On-Premise system. All the apps are running inside Fiori Launchpad.

How I'm doing this now: I have a deployed app that holds my SomeUtilFunction.js (e.g.: /sap/bc/ui5_ui5/sap/myReusableFunctionality), which app I'm referencing in the manifest.json of the other apps (e.g.: defined under dependencies as a component and pointing to the location of the app via resourceRoots by using a path relative to the parent directory of the component like ../sap/bc/ui5_ui5/sap/myReusableFunctionality/ ).

The current implementation is based on what I've been reading in blogs like blog1, blog2 but, at a first glance, what is recommended there doesn't seem to be on par with the official documentation which states the following for resourceRoots: ".myname": "./myname" //only relative paths inside component are allowed, no "..", for real sub-packages of the component only (must not be used for component namespace itself).

So, is the above a correct usage of resourceRoots? If not, what would be the recommended way of implementing the use case described above?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Oct 16, 2019 at 05:16 PM

    For your scenario, you can go by creating a library as it is not a component reuse scenario.

    Secondly, I think it depends on the version of your ui5 app. In old version you might have to do like those blogs suggested or you can try the below solution (it might work in old versions as well, not sure).

    https://blogs.sap.com/2018/08/16/how-sap-web-ide-supports-development-of-sap-fiori-reusable-libraries/

    After doing the above steps, You can see the neo-app.json getting update with the path and which is why u are able to load the library from the workspace locally.

    You can also check the manifest.json updated with the library namespace.

    Next deploy and test in launchpad, it will work like a charm without resource roots. It only works in launchpad and use /n/ui2/flp tcode to test, i think there is another path with abap something which doesn't work If i remember correclty.

    BR,

    Mahesh

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.