Skip to content

api import

Ayhan Rashidov edited this page Sep 5, 2022 · 3 revisions

$.import API

Imports a server-side JavaScript library artifact.

Reference

The library is a design-time artifact located in the repository. JavaScript library design-time artifacts have the suffix '.xsjslib'.

SAP Help

https://help.sap.com/doc/3de842783af24336b6305a3c0223a369/2.0.03/en-US/$.html#import

Module

https://github.com/codbex/codbex-kronos/tree/main/modules/api/api-xsjs/src/main/resources/META-INF/dirigible/kronos/import

Sample Usage

root/
|-- sap
    |--import.xsjs
    |--myapp
          |--lib
             |--math.xsjslib
// import .xsjslib to our file using $.import api ("package","library")
//in our case package equals "sap.myapp.lib"
var mathlib = $.import("sap.myapp.lib","math");
var response = require('http/v4/response');

var square = mathlib.square(6);
var multiply = mathlib.multiply(4,9);
var division = mathlib.division(9,3);

response.print("number is "+ square);
response.print("devision = "+ division);
response.print("multiply = "+ multiply);

Coverage

  • Parameters:
Name type Description
package string The name of the package in which the library object is located
library string The name of the library object in the repository (without the suffix .xsjslib)

Unit Tests ⚠️

https://github.com/codbex/codbex-kronos/tree/main/modules/engines/engine-xsjs/src/test/resources/META-INF/dirigible/test/kronos/import

Integration Tests ❌

✅ - Feature implemented and working as supposed.
⚠️ - Feature partially implemented and needs to be finished.
❌ - Feature not implemented yet.

Clone this wiki locally