on 05-08-2008 7:26 PM
hello experts,
Iam very new to java,
iam trying a simple user defined function where I want to throw an exception incase my employee id is blank,such that it should show my exception text("emp id is blank") in my moni transaction if i pass a blank value.
Can this be done without creating a package by some small code in udf's?.
I refered to this blog,(/people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphical-mapping)
but this way suggests to create a custom exception in a package etc.. are there any standard exceptions i can throw?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Liang,
I saw the thread you posted.. it is that of a Number gformat ecxeption, i tried the same with the null value exception but its not workign, its giving me some syntax error problem
below is my code,,
any thoughts from you or anyone about it?
//write your code here
if (a.length == 0);
throw new NullValueException('Value is Null);
else
result.addValue(a[0]);
its returning me syntax error saying else statement syntax and nullvalue syntax..
please help me.
thanks.
Hey Amir,
thanks for the check..
this is my new code and it keeps giving me the error that a ")" is expected.
//write your code here
if (a.length == 0)
throw new NullValueException (Value is Null) ;
else
result.addValue(a[0]);
I also tried to put mycomment value is null into "".
any corretcions i need to do on this one to make it work?
thanks.
Hi All,
I wanted the exception to be thrown based upon if the 'value' exists..the exists checks if the node exists or not..
Also the previous 2 solutions did not work.
this pone works well. it check if the value exists or not and then throws an exception.I also wanted my own string in this exception so i did not try it with the standard functions.
Working code:
String ret = "";
int c = a.length();
if (c == 0)
{
throw new RuntimeException(b);
}
else
{
ret = a;
}
return ret;
Thanks for your help anyway..!!
Edited by: XI_User XI on May 9, 2008 10:24 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if (a.length == 0);
As I can see, the code has not done that you really want.
It means you just check the queue length is 0 or not, in other words, you check if the incoming message has the tag or not.
standard function "exist" does the exact work.
Based on your requirment, you would like to check if the ID field is blank or not, this means you always have the tag passed in your incoming xml file, you just want to check if there is blank payload or not, this way, you can go ahead just use standard function as ujjwal kumar mentioned.
Regards.
Liang
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
As you are new to java,you could have done it without using udf.
You can use a simple if else standard function,and get away with it.
The use of udf has to be done when standard functions are not able to fix the issue.
reward point if helpful
regards,
ujjwal kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
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.