on 05-08-2008 2:27 AM
Hi
I want to check the whether the fiels conatins any value or not in mapping ... if not i want to raise the exception using the UDF
DO any one have sample code for writing the UDF
SV
String input
int a;
if(input.length<0)
{
a=hello;
}
here string input is the input parameter for the udf i.e the field value.
if the input lenght is less then zero i.e no value for the field we are assigning string hello
to an integer which will throw an exception.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
i used the UDF
int b = a.length;
if (b == 0)
throw new RuntimeException("Record is Empty");
else
result.addValue (a[0]);
when i tested the mapping in from test tab with out passing any value ...its not throwing any exception
Any idea
SV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi SV
what is your requirement first that should br clear.
i am giving you two UDF
1) i have written this uDF for string and comparing the field value XYZ
2) i am entering a string and its returning aa string which starts from the index of your input fixed length
int len = a.length();
String res = "";
String temp = "";
if ( len >= 10)
{
temp = a.substring(0,10);
}
if ( temp.equals("XYZ"))
{
res = temp;
}
else
{
res = "";
}
return res;
=======================================
String fixed = "ABCD";
String res = "";
int index = -1;
index = a.indexOf(fixed);
if (index == -1)
{
res = "NO INDEX FOUND";// or if u wanna set it as null res = "";
}
else
{
res = b.substring(index4,index12);
}
return res;
===
hope these may solve your problem
Thanks
Sandeep sharma
If helpful reward points
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The following blog is what you are looking for:
[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3069] [original link is broken];
just change the ThrowException udf in the blog like:
public void ThrowException(String[] inputfield,ResultList result,Conatiner container){
if(inputfield.length==0)
ExceptionThrower.fire("Filed doesn't contain any value");
else
result.addValue(inputfield[0]);
}
*Reward points if helpful...
--Sankar Choudhury
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.