cancel
Showing results for 
Search instead for 
Did you mean: 

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

malteschluenzkc
Participant
0 Kudos

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

View Entire Topic
former_member666312
Active Participant
0 Kudos

Hi Malte,

i think one option you can try is by passing these values as headers in the content Modifier and read those headers (Message also as constant in the Content Modifier).

This is a good point to test, i will try this.

Thanks and Regards,

Vijay.

malteschluenzkc
Participant
0 Kudos

Hi Vijay,

thank you for your response!

I also thought about that solution, but I didn't like this very much, because that is adding a lot of effort for development and also technically on the runtime because it is a couple of additional steps and operations.

Do you know if the behaviour of the groovy script block with the function name is as expected?

Best regards,
Malte