Skip to Content
0
Jun 07 at 06:09 AM

How to use parameters in the call to the SAP Cloud Integration Script Collection?

101 Views

Hi experts,

I have a question on how to handle parameters within a script collection for SAP Cloud Integration (Neo).

Currently, we have a standardized logging script:

[...]
15 import com.sap.gateway.ip.core.customdev.util.Message;
16 import java.util.HashMap;
17 import groovy.json.*;
18 import groovy.xml.*;
19 import com.sap.it.api.asdk.datastore.*;
20 import com.sap.it.api.asdk.runtime.*;
21
22 def Message log01(Message message) {processData("1", "Log01_Message_To_ERP", "Message To ERP:", message);}
23 def Message log02(Message message) {processData("2", "Log02_Response_From_ERP", "Response From ERP:", message);}
24
25 def Message processData(String id, String logProperty, String name, Message message) {
26    def map = message.getProperties();
27    def body = message.getBody(java.lang.String) as String;
28    if(map.get(logProperty).equals("true")) {
29        def logConfig = map.get("SAP_MessageProcessingLogConfiguration");
30        def logLevel = (String) logConfig.logLevel;
31
32        def messageLog = messageLogFactory.getMessageLog(message);
33            
34        if(messageLog != null)   {  
[...]
76            // Create MPL attachment as log
77            if((logLevel.equals("DEBUG") || logLevel.equals("TRACE"))) {
78                messageLog.setStringProperty("Logging#" + id, "Printing Payload As Attachment");
79                messageLog.addAttachmentAsString(id + ": " + name,body, "text/plain");
80            }
81        }
82    }
83    return message;
84}

As you can see we defined in lines 22 & 23 two logging points for this iflow which just call the processData function. These lines are specific for an iflow (in more complex flows it explains a bit more where the log point is without knowing the flow indepth) and hence I cannot move this script to the script collection.

My issue is, that I cannot move the processData([...]) calls to the Script Function of the step, as I cannot provide the message from there, only a function name.
Do you have an idea how to handle this?

Best regards,
Malte