on 06-12-2006 11:25 PM
Hi all,
How can I pass in the actual "node" as a parameter to a user defined function? Such as passing in an IDOC segment tag <MATNR> as the parameter to see if it exists in the inbound idoc structure? Is this possible and how can it be done? Thank you for any help.
Jui,
Exists checks wether the tag is present in the incoming XML.But i guess the limitation is when the field is 0..unbounded it gives unexpected results...!Michal is absolutely right to use UDF instead of exists..!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jui,
This can be done. Here it goes...
Create a UDF with cache as "Context". If you want to check for more nodes, include it as b,c,d... parameters in the UDF. (Default is "a"). And the code looks like the following.
Here I have used it for checking 3 nodes. The logic behind the code is that if all the 3 nodes exist, then it will concatenate all the three fields and produce the result node, if any one of them doesnt exist, then it will concatenate only the remaining fields.
try{
if(a.length != 0 && b.length != 0 && c.length != 0)
result.addValue (a[0] + b[0] + +c[0]);
else {
if(a.length == 0 && b.length != 0 && c.length != 0)
result.addValue( b[0] + c[0]);
if(a.length != 0 && b.length == 0 && c.length != 0)
result.addValue(a[0] + c[0]);
if(a.length != 0 && b.length != 0 && c.length == 0)
result.addValue(a[0] + b[0]);
}
}catch (ArrayIndexOutOfBoundsException e)
{
result.addSuppress();
}
Regards,
Prasad U
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
matnr is not a node but a field
so you can pass your field to the UDF and check
if there's any value inside?
or use the standard <b>exists</b> function
you can use the exist function with nodes too
you can also use this exists function (NODE functions)
to check if the node,fields exist and
return only the result to your UDF if you need
to do some more complex logic
Regards,
michal
-
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry I wasn't being clear with my wording. I know I can check whether a field is there with the exists function, or check if the field contains a value.. but what I want to know is exactly how I can pass the actual tag to a UDF to check if it is there? Basically how does the exists function work? I would like to know this because I want to write a more sophisticated function that is like exists but does a little more. Thank you.
Hi,
You could use a String array, (String[] a ) in the UDF signature, which will accept the field as input. (In case there are multiple occurences of the field).
Or you could use a String object (String a)to accept the value of this field.
In your UDF, you could check if it exists using,
if(a != null) {...}
Regards,
Smitha.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
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.