on 07-17-2009 10:19 AM
am mapping dummy to a segment E1MAKTM-MAKTX.
Dummy is a field which will contain the text this text needs to be split for every 4 character and populate it into multiple E1MAKTM.
This is the requirement.
If the input is
Thanks for answering my posts
the outpu should be
Than
ks fo
rans
weri
How can do an UDF where i pass a single value and getting a result as an array
Thanks it worked
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Patrick,
It worked. Now i need only more functionality in the code that it shoud not split in the space.
If the length we are considering is 10.
for the input " Thanks for answering my posts".
then the ouput should be
Thanks for
anwering
my posts
Is it possible to include this functionality also in the code
I have tested the below code is working fine .Choose context while creating the UDF
String input1=input[0];
int cnt=4;
for(int i=0;i<input1.length();i++)
{
if(i+4<=input1.length()){
result.addValue(input1.substring(i,cnt));
i=cnt-1;
cnt=cnt+4;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks guys..
i tried with Fathima's code. Am getting a runtime exeption when i clicked on Displyqueue of the udf i used
RuntimeException in Message-Mapping transformation: Exception:[java.lang.ArrayIndexOutOfBoundsException: 0] in class com.sap.xi.tf._Lennox_MDM_Material_create_2_MATMAS05_ method test$[com.sap.aii.mappingtool.tf3.CBufIter@20bed219]
what shall we do.
Hi,
this (context) UDF should work:
int startIndex = 0;
while (startIndex < a[0].length()) {
if (startIndex < a[0].length() -4)
result.addValue(a[0].substring(startIndex, startIndex + 4));
else
result.addValue(a[0].substring(startIndex, a[0].length()));
startIndex += 4;
}
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use the function substring to break the string . eg : for the first 4 characters substring(0,3) then next 4 characters substring(4,7) like that you break the string into small components.
Thanks
Arijit Guha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
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.