on 03-05-2008 12:15 PM
Is it possible to have UDF do the following:
I have a queue e.g.
A
B
C
<ContextChnage>
D
E
F
<ContextChange>
G
H
I basically want the UDF to take all the values of one context and concatenate them together and return the result.
So the result should be.
A B C
<ContextChnage>
D E F
<ContextChange>
G H
Could someone let me know how to do this?
Hi Mendez,
Use this UDF:
public void myUDF(String[] a,ResultList result,Container container){
int len=a.length;
String temp[]=new String[len];
int k=0;
String val="hai";
for(int i=0;i<a.length;i++)
{
if (!(a<i>.equalsIgnoreCase(ResultList.CC)))
{
val+=a<i>;
}
else
{
temp[k]=val;
k++;
val="";
}
}
temp[k]=val;
k++;
for(int i=0;i<k;i++)
{
result.addValue(temp<i>);
//result.addContextChange();
}
}//end of the function
Put the cache value as context.This would work.
Thanks,
Bhargav.
Note:Award Points if found useful.
Edited by: bhargav gundabolu on Mar 5, 2008 3:52 PM
Edited by: bhargav gundabolu on Mar 5, 2008 3:54 PM
Edited by: bhargav gundabolu on Mar 5, 2008 3:55 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I tried it but I got the following error:
Source code has syntax error:
/usr/sap/XXX/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapc200ca30eac911dcb3df000d60de069c/source/com/sap/xi/tf/_MM_Back_2_.java:98: 'class' or 'interface' expected public static void main(String[] args) throws Exception{/!_$ClNRep_/_MM_Back_2_ st = new /!_$ClNRep_/_MM_Back_2_(); st.testExecute(); } ^
/usr/sap/XXX/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapc200ca30eac911dcb3df000d60de069c/source/com/sap/xi/tf/_MM_Back_2_.java:99: 'class' or 'interface' expected } ^
/usr/sap/XXX/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapc200ca30eac911dcb3df000d60de069c/source/com/sap/xi/tf/_MM_Back_2_.java:100: 'class' or 'interface' expected ^ 3 errors
Hi,
This is because you might have not removed the last closing brace ( '}' ).remove that and test it.
This error occurs when you have opening which is not closed properly at the end or if any extra closing braces occur.
In this UDF the first opening brace should occur after the String temp[] decleration statement.
and after the result.addValue(temp); there should be only one closing brace.
Thanks,
Bhargav.
Mendez,
Here you go
StringBuffer sb=new StringBuffer("");
for(int i=0;i<value.length;i++)
{
if(!(value<i>.equals("__cC_")) || (i==value.length-1))
{
sb.append(value<i>);
}
if(value<i>.equals("__cC_") || i==value.length-1)
{
result.addValue(sb.toString());
if(i!=value.length-1)
{
result.addContextChange();
}
sb=new StringBuffer("");
}
}
UDF: http://www.flickr.com/photos/23855877@N07/2311960865/sizes/o/
Results:http://www.flickr.com/photos/23855877@N07/2311960861/sizes/o/
raj
I removed the brace at the end and get the following:
Source code has syntax error: /usr/sap/XXX/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map43d000e0eace11dc9654000d60de069c/source/com/sap/xi/tf/_MM_Back_2_.java:72: cannot resolve symbol symbol : method equalsIgnoreCase (java.lang.String) location: class java.lang.String[] if (!(a.equalsIgnoreCase(ResultList.CC))) ^
/usr/sap/XXX/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map43d000e0eace11dc9654000d60de069c/source/com/sap/xi/tf/_MM_Back_2_.java:88: addValue(java.lang.String) in com.sap.aii.mappingtool.tf3.rt.ResultList cannot be applied to (java.lang.String[]) result.addValue(temp); ^ 2 errors
function myudf(String a[],ResultList result,Container container)
{
String temp[];
int k=0;
for(int i=0;i<a.length;i++)
{
if (!(a.equalsIgnoreCase(ResultList.CC)
{
temp[k]=new String[30];
temp[k]=temp[k]+a;
k++;
}
}
for(int i=0;i<k;i++)
result.addValue(temp);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
function myudf(String a[],ResultList result,Container container)
{
String temp[];
int k=0;
for(int i=0;i<a.length;i++)
{
if (!(a<i>.equalsIgnoreCase(ResultList.CC)
{
temp[k]=new String[30];
temp[k]=temp[k]+a<i>;
k++;
}
}
for(int i=0;i<k;i++)
result.addValue(temp<i>);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
11 | |
11 | |
10 | |
9 | |
8 | |
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.