Skip to Content
0

how to call a JSView from an XSJS file?

Jun 12, 2017 at 07:36 PM

82

avatar image

I know I can call other JS files from XSJS by making a .xsjslib file. I would like to be able to call a JSView instead. Is this possible?

Note: the reason for me to this is that I can then use the sapui5 libraries and make it easier to import external libraries to my code.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Thomas Jung
Jun 12, 2017 at 09:32 PM
2

I'm afraid it doesn't work like that. XSJS executes on the server side and SAPUI5 executes on the client side. A small block of code you might isolate and rewrite as XSJSLIB, but that's the only way to reuse JavaScript in XSJS in XSC. If you really want to use external modules in XSJS, I suggest migrating to XS Advanced. There the XS runtime is based upon Node.js and you can call external node modules with the $.require API.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thank you for your reply Thomas. Unfortunately migration is not an option. Do you have a reference API for XSJS or formal documentation I can use? I've been able to find simple examples but I would like to have something better I can refer to when I need to.

0

Of course the Reference API for XSJS is available in the online help documentation: https://help.sap.com/http.svc/rc/3de842783af24336b6305a3c0223a369/2.0.01/en-US/index.html

0