Skip to Content
0

Retrieve messageID in Custom Function

Jul 24, 2017 at 03:28 PM

185

avatar image

Hello,

what would be the recommended option to retrieve a messageID in a custom function (groovy)?

Is there any documentation on standard methods that can be used in groovy script to achieve this?

Thank you for your help!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Sriprasad Shivaram Bhat Jul 25, 2017 at 08:45 AM
1

Hello Florian,

Below code will work for you.

import com.sap.it.api.mapping.*;

//Add MappingContext as an additional argument to read or set Headers and properties.

def String customFunc(String input_date,MappingContext context){
    
    //Read property Value and store it in String
    String propVal = context.getProperty(SAP_MessageProcessingLogID);
    propVal_Str = propVal.toString();
    
    
  return propVal_Str;
    
}

Regards,

Sriprasad Shivaram Bhat

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Great, thank you for your help! This solved my issue!

0
Srinivas Sistu Jul 24, 2017 at 03:33 PM
0

Hi,

have you tried

String messageId = message.getPropoerty("SAP_MessageProcessingLogID")

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hello, thank you for your reply. Just tried but get the following error message:

The root message is: Exception:[com.sap.aii.mappingtool.tf7.rt.BehaviorInvocationException: groovy.lang.MissingPropertyException: No such property: message for class: Script2] in class com.sap.aii.mappingtool.tf7.ScriptHandler method getMessageID

Any idea what is causing this error?

0

could you pls try this.

import com.sap.gateway.ip.core.customdev.util.Message;

def Message processData(Message message) {

//Body def body = message.getBody();

def mplId = message.getProperty("SAP_MessageProcessingLogID");

return message;

}

0