cancel
Showing results for 
Search instead for 
Did you mean: 

how to call a JSView from an XSJS file?

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate

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.

Former Member
0 Kudos

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.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

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