on 03-21-2016 8:18 PM
Hello Folks,
I have a IDOC to file scenario.
In IDOC one of the segment has values available in the format MOT=2;POL=;USPOE=3801;FC=70;W=230;CCAI=2013.
The values are separated by semicolon ;.
Now I have to send each of these values to separate field of Output File.
For example;
2 to field1,
Blank to field2
3801 to field3
70 to field4
230 to field5 and
2013 to field6
Also, please note here the string in IDOC is not a fixed length one. It depends on whether the End User fill some value or not According field is populated
also UPSOE can be 3 digit or 4 digit value and FC can come as 70.00 or 70.0 or 70 depending on how user fill the value.
So basically the search in the string is based on keywords like MOT, POL etc.
Please let me know how to achieve this?
Regards,
Sachi
you can use regex - user defined function with 3 input parameters.follow the below code.. For each fields you just need to call the UDF and pass the required params
Assign under Import..
java.util.regex.Matcher
java.util.regex.Pattern
Parameter
sInput (takes Idoc input data string as MOT=2;POL=;USPOE=3801;FC=70;W=230;CCAI=2013)
Sval1 (define as constant for each target field as MOT= or FC= or USPO )
Sval2 = ; (Constant ; )
UDF
Pattern p = Pattern.compile(Pattern.quote(sVal1) + "(.*?)" + Pattern.quote(sVal2));
Matcher matcher = p.matcher(sInput);
if (matcher.find()) {
return matcher.group(1);
}else
return "false";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.