cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve messageID in Custom Function

floriangu
Participant
0 Kudos

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!

Accepted Solutions (1)

Accepted Solutions (1)

Sriprasadsbhat
Active Contributor

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

floriangu
Participant
0 Kudos

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

Answers (1)

Answers (1)

srinivas_sistu
Active Contributor
0 Kudos

Hi,

have you tried

String messageId = message.getPropoerty("SAP_MessageProcessingLogID")

floriangu
Participant
0 Kudos

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?

srinivas_sistu
Active Contributor
0 Kudos

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;

}