on 03-21-2017 12:05 PM
Message mapping my source string having 150 Char but I want to break up 20 Char 20 char put in the target mgs .
We need write UDF or we can do any other way
Thanks for given answers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chandra,
Please find the logic below.
Mapping screen
UDF Elements
Count Parameter
In the code, Count is used as constant which specifies the length of each string that should be split from the Input String. This can be passed as normal constant or parameter. In your case, it should be 3.
The parameter can be varied based on the requirement.
Length Condition Handled
If the input string can't be split up into equal sub strings, [For e.g AAABBBC(length7) is to be split into strings of length 3] we are padding tilde symbol at last of source string for initial splitting and finally removing the same while posting to the target.
UDF Code
int len = Inp[0].length();
int Mod = len % Count[0];
if( Mod != 0)
{
Inp[0] = String.format("%0$-" +(len+Count[0]-Mod)+ "s", Inp[0]).replace(' ','~');
}
String out;
for(int i=0;i<len;i=i+Count[0])
{
out = Inp[0].substring(i,Count[0]+i);
if( i == len-Mod)
{
out = out.replace("~","");
}
Res.addValue(out);
}
Mapping Test 1 [Count -3]
Mapping Test 2 [Count -3]
Mapping Test 3 [Count -4]
Could you please let us know if this is helpful.
Regards
Baski
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chandra,
You mean to say target is one field with occurrence, 0..unbounded ?
Regards
Baski
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have you checked his link
https://wiki.scn.sap.com/wiki/display/XI/Split+Mapping+using+UDF
?
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Source field
AAABBBCCCDDD…….YYYZZZ
Target filed
I want break up 3 , 3 ,3 char like
Field1AAA
Field2BBB
Field3CCC
Field4DDD
.
.
FieldNZZZ
I think Countable Char means we can use substring,, If we get more char What we have to do?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please give example of source and target message.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.