on 02-04-2015 10:35 AM
Hi experts,
just a maybe simple question:
In a UDF is possible to use throws?
When I use "Create a new function" the first row:
public String example(String valueAsString,Container container){
is not modifiable.
my need is to have this:
public String example(String valueAsString, Container container)
throws IllegalArgumentException, NumberFormatException {
Is possible?
Thanks
Fabio
Fabio,
When a UDF is created.
public String calculate(String var1, Container container) throws StreamTransformationException{
}
It can only throw StreamTransformationException. We can not add more exception classes.
Why we can not add more exception classes?
As you know, the graphical message mapping will compile into Java class and run on PI Java server. The Java class which is calling the UDF should also handle exceptions thrown by UDF. If PI developer can add all sort of exception classes, how will PI Java class know, which exception it should handle. To avoid it, SAP has restricted (SAP's design), UDF can only through StreamTransformationException.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Additionally, if your intention is to raise exception at the message mapping whenever those two exception occurs in your UDF logic, you can just catch those exception, and rethrow them as StreamTransformationException with the associated text.
try {
//Do something
} catch (NumberFormatException e) {
throw new StreamTransformationException("NumberFormatException Text", e);
} catch (IllegalArgumentException e) {
throw new StreamTransformationException("IllegalArgumentException Text", e);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.