on 2024 Apr 01 6:53 PM
Hi All,
Please help me in groovy script to extract the highlighted value from below message and set it as property"DOCNUM"
<?xml version='1.0' encoding='UTF-8'?>
<RootNode>
<Payload>
EDIXX3SSIP2000131 0000131 DELIN2.002.OD.02.S03 DELSCHD031 0000000000039067
EDIMSG
MID 1
MID 20231221
MID 0000
</Payload>
<MsgHeader>
<EndPoint>ABCDE</EndPoint>
<EntryID>XXXYYY</EntryID>
<RetryCount>2</RetryCount>
</MsgHeader>
</RootNode>
Your help would be highly appreciated !
Thanks in advance
Jeevitha
Request clarification before answering.
Hello @Jeevitha_04 ,
I hope this solution aligns with your needs. I came across this suggestion while using ChatGPT.
Considering that your ID is always 16 digits long, I believe this solution might be suitable for your case. Could you please provide more details or clarify if this fits your requirements?
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
def Message processData(Message message) {
//Body
def body = message.getBody();
def rootNode = new XmlSlurper().parseText(body);
def payload = rootNode.Payload.text();
def pattern = ~/(\d{16})/
def matcher = (payload =~ pattern)
if (matcher.find()) {
def matchedDigits = matcher.group(1)
} else {
println "No match found"
}
def properties = message.getProperties();
message.setProperty("newProperty", matcher.group());
return message;
}
Best regards,
Burak
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
53 | |
8 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.