on 08-07-2007 1:11 AM
Hi
I have a scenario where sender is file. In file there is a field Total records.
I need to validate Total records field with the total records in the file using UDF..
Can any suggest me the how to write the cod efor this..
venkat
Hi Venkatesh,
Do you want to do this validation in Message Mapping step?
if its invalid or valid, what action you want to take?
Cheers,
Jag
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Venkatesh,
In your source structure should Detail Records count equal to Total Record Count?
if yes,just create <b>Context</b> UDF and pass the following 2 inputs
1. <b>DetailRecord</b> -> RemoveContext
2. <b>TotalRecord</b>
and inside UDF write java code for validation
suppose if your inputs are a[](DetailRecord) and b[](TotalRecord)
{
int scnt = a.length;
int tcnt = Integer.parseInt(b[0]);
if( scnt != tcnt)
{
//write code to trigger an alert(from the following weblog)
}
}
To Trigger alert from UDF just go through the following weblog
/people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function
Cheers,
Jag
Hi Venkat,
if you want to trigger Alert for Header node. you need one more UDF with one input
i.e <b>Header</b>-> <b>exists</b>(Node function) ->UDF
Input to UDF would be either <b>true</b> or <b>false</b>.so Inside UDF you have to write java code like if <b>false</b>(Header Not existing) trigger Alert.
Cheers,
Jag
Hi Venkat,
what i mean is you have to create new UDF if you want to validate Header node.
UDF input is output of <b>exists</b>(it comes under Node functions) standard function.
This<b> exists</b> will return <b>true</b> if <b>Header</b> node occurred,
otherwise <b>false</b>.
so inside UDF you need to check for <b>true</b> or <b>false</b> values.
if its <b>false</b> it means header node didnt occurred then trigger Alert.
Header(from Source structure)->exists(Node function)->UDF
Cheers,
Jag
Hi Jagdish
I wrote the code like
public void TotalRecords(String[] TotalRecord,String[] DetailRecord,ResultList result,Container container){
{
int scnt = DetailRecord.length;
int tcnt = Integer.parseInt(TotalRecord[0]);
if( scnt != tcnt)
{
throw new RuntimeEception("Error in the Total Records field");
}
Is that right or need to do any modifications
Which java package i have to import for Runtime Exception
venkat
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.