Introduction
As described in the article Modularising CPI Groovy scripts using POGO , there is a concept of splitting code into smaller modules by using multiple scripts within an ifFow. However, the explanation applies only to Groovy.
I am looking for a similar approach using JavaScript, which is also available in SAP CPI.
POC - additional function outside of 'processData'
As a first step, I prepared POC using a single script. It contains the main function (processData) and an additional helper function defined outside of it. Script below :
This approach works correctly. After testing via Postman, i received the expected results.
POC - additional code as a seperate script (failure result)
In the next step, I tried to move the helper logic into separate script to improve readability and maintainability.. So i copied the code into a new script called "JS_ExtScript". Then in my main script "JS_withExtScript", I attempted to use the "importClass" syntax with the path src.main.resources.script.<script_name>.<class_name> .
However, the tests ended with an error .
I did some research and found the following resources:
- Try use JavaScript scripting instead of Groovy scripting in your CPI project , where someone from SAP recommended to check functions like defineClass, load, loadClass, but none of these worked in my case.
- SAP Integration Suites javascript load library, similar question regarding my topic was raised, but no clear solution was provided. The author ended up keepin all logic in a single script, similar to my initial POC which works fine but this is not what i am looking for.
Looking for you help. Thanks in advance !
Request clarification before answering.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.