on 02-27-2014 4:58 PM
Dear all,
I have a scenario where the source and target structures are as follows :
The output for the above transformation logic is
The occurrence for field id in source and target is 1:1 Even if i don't provide the input value for id field,
system is not throwing any runtime exception.But if the field tag id is missing in incoming payload, then
system throws exception.
1) *** How can i raise a exception it the value for field id is empty
2) As the target structure occurrence for field id is 1:1 why system doesn't throw exception for null value
Regards
Koti Reddy
Hello,
1) Simply use below UDF and throw custom exception in case ur field is empty
Input: var1
Execution type: single value
if(var1.equals(""))
{
throw new RuntimeException("Input field is empty");
}
else
{
return var1;
}
}
2) There is a difference between null (field itself is not coming in input xml) and blank value. Empty string is a valid data as a result ur mapping hasn't been failed.
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Amit,
Thanks for the input. Transformation logic is working fine. Error description in SXMB_MONI is as shown below
In the above image, it is not showing the error description "input field is empty" that was provided in UDF. As alerts were already configured for the scenario, is there any possibility to get the above description for the error.
Regards
Koti Reddy
Hi Amit,
Along with the mapping validation on field id, i have to include the name of the employee in exception as "Input field is empty for : NAME"
so that the user can easily identify that Input value is empty for field id while processing the record for so and so NAME.
How to meet this requirement in UDF.
Regards
Koti Reddy
Hi,
If you want to raise a custom exception in mapping use the below udf.
Ex:id -->mapwithdefault-->udf-->id
if(!id.equals("")){return id;}
else{throw new StreamTransformationException("Source field \"id\" value is empty");}
As above said in your example it didn't throw default error because you are passing empty value(tag without any value).
It will throw error when you pass null value i.e (without tag )
Regards
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Kumar,
As described by other members earlier, make use of standard function mapWithDefault ("") followed by UDF throwing StreamTransformationException in case the value is empty. I don't think you can fulfil such requirement with the customized error message with pure standard graphical mapping functions, without UDF.
May I also wonder why usage of UDF is not an option for you?
Regards,
Vadim
1) *** How can i raise a exception it the value for field id is empty
You need to impliment the check to throw the error
2) As the target structure occurrence for field id is 1:1 why system doesn't throw exception for null value
You are sending a blank value " " and the same is being passed. if you remove the tag from source xml it'll throw the error
Message was edited by: Hareesh Gampa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
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.