on 02-25-2009 10:57 AM
Hi....
I am having input File which is having only one field..Below is the input file structure.
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MTO_Check_Request xmlns:ns0="http://axis.com/file_upload">
<FileName>Test_Master</FileName>
</ns0:MTO_Check_Request>
The Input value should be splitted .
Then My output should like below format.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MTI_Check_Response xmlns:ns0="http://axis.com/file_upload">
<FileName>Test</FileName>
<FileType>Master</FileType>
</ns0:MTI_Check_Response>
Can you please help how to do the mapping. If any UDF required can you please provide.
Thanks & Regards,
Leela
Hi,
Use like below..In the global variables(String[] arr = null; )and use as per malini ans,
Select context or queue for udf:
Split 1:
arr = a[0].split("_");
result.addValue(arr[0]);
Split 2:
arr = a[0].split("_");
result.addValue(arr[1]);
Regards,
Prakasu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leela,
Here is an alternate solution:
FileName --> UDF1 --> FileName
UDF1 and UDF2 are both of value type
Here is the code for UDF1, argument type is: input
int c[] = null;
c = new int [1];
c[0]=input[0].indexOf("_");
result.addValue(input[0].substring(0,c[0]));
FileName --> UDF2 --> FileType
Here is the code for UDF2, argument type is: input1
int c[] = null;
c = new int [1];
c[0]=input1[0].indexOf("_");
result.addValue(input1[0].substring(c[0]+1,input1[0].length()));
Let me know if this worked.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
What is the function paramete for ur UDF? is it value or queue or context. If it is value change to queue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It is because u declare it as a string array ie String array and in function it is used as string. That might be causing the error . Give it as arr[] insted of arr.
Edited by: sivarama krishna on Feb 25, 2009 1:02 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It is because u declare it as a string array ie String arr[]; and in function it is used as arr. That might be causing the error . Give it as arr[] insted of arr.
Edited by: sivarama krishna on Feb 25, 2009 12:58 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Declare it as String arr = a[0].split("_");
sorry i have typed it wrong in the previous mail.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Leela,
the error is because u havent declared the arr . Declare it as : arr = a[0].split("_");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi...
If i include that i am getting the below error.
Source code has syntax error: /usr/sap/APD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map51268d30033311dea6d6002264977f6e/source/com/sap/xi/tf/_MM_Check_DB_Request_.java:69: incompatible types found : java.lang.String[] required: java.lang.String String arr = a[0].split("_"); ^ /usr/sap/APD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map51268d30033311dea6d6002264977f6e/source/com/sap/xi/tf/_MM_Check_DB_Request_.java:70: array required, but java.lang.String found result.addValue(arr[0]); ^ /usr/sap/APD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map51268d30033311dea6d6002264977f6e/source/com/sap/xi/tf/_MM_Check_DB_Request_.java:76: incompatible types found : java.lang.String[] required: java.lang.String String arr = a[0].split("_"); ^ /usr/sap/APD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map51268d30033311dea6d6002264977f6e/source/com/sap/xi/tf/_MM_Check_DB_Request_.java:77: array required, but java.lang.String found result.addValue(arr[1]); ^ 4 errors
Regards,
Leela
Hi Leela,
use this Below UDF...
public void split1(String[] FileName,ResultList result,Container container)
{
int idx=0;
int tokenCount;
String ret[]=new String [3];
StringTokenizer st=new StringTokenizer(FileName[0]);
tokenCount= st.countTokens();
while (st.hasMoreTokens())
{
ret[idx]=st.nextToken(); // here idx should be in square brackets
idx++;
}
for (idx=0;idx<tokenCount; idx++)
{
result.addValue(ret[idx]); // here idx should be in square brackets
}
} // end of UDF
Thank You,
Madhav
Note: Points If Useful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leela,
Write a UDF and the input of the UDF should be the text node or input node.
In the UDF use this function:
String [] asValues = strInput.split("_");
and return the values using a for loop.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leela,
Would you be able to provide more examples aside from test_master?
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use a UDF to split the input on "_"
Declare a global varible String arr[]; under initialization section
public void split1(String[] a,ResultList result,Container container)
{
arr = a[0].split("_");
result.addValue(arr[0]);
}
public void split2(String[] a,ResultList result,Container container)
{
result.addValue(arr[1]);
}
FileName>split1->FileName
FileName->split2->FileType
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi..
I have used your udf. But i am getting the below errors.
/usr/sap/APD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map8baf0ec0033111deba47002264977f6e/source/com/sap/xi/tf/_MM_Check_DB_Request_.java:68: cannot resolve symbol symbol : variable arr location: class com.sap.xi.tf._MM_Check_DB_Request_ arr = a[0].split("_"); ^ /usr/sap/APD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map8baf0ec0033111deba47002264977f6e/source/com/sap/xi/tf/_MM_Check_DB_Request_.java:69: cannot resolve symbol symbol : variable arr location: class com.sap.xi.tf._MM_Check_DB_Request_ result.addValue(arr[0]); ^ /usr/sap/APD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map8baf0ec0033111deba47002264977f6e/source/com/sap/xi/tf/_MM_Check_DB_Request_.java:75: cannot resolve symbol symbol : variable arr location: class com.sap.xi.tf._MM_Check_DB_Request_ result.addValue(arr[1]); ^ 3 errors
Regards,
Leela
Use substring standard text function.
Regards,
Prateek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use the below UDF to split based on the token pattern("_" in your case).
public static String TokenAt(String sInput, String sPattern, String sTokenNo) {
int iTokenNo = 0;
try {
sToken = sInput.split(sPattern);
int iNoOfTokens = sToken.length;
iTokenNo = Integer.parseInt(sTokenNo);
iTokenNo = ((iTokenNo > iNoOfTokens) ? iNoOfTokens : iTokenNo);
} catch (Exception e) {
return "";
}
return sToken[iTokenNo - 1];
}
Regards,
Swetha.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
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.