on 01-31-2014 6:21 AM
Hi Experts,
In our project there is a field which is populated with the Idoc fields. The scenario is Idoc to file and multiple idocs can come at one point of time.
So for my concerned field, the data is coming based on several conditions like payrun, company code, payment method etc...
Previously I was using the graphical mapping but now as many conditions are getting added in to the mapping, I am thinking of going with the advanced UDF.
The sample conditions are based mainly on payment method, company code, bank and one other field.
I have written an UDF and it is giving me the correct output but one more null is getting added after the last context change , which was not happening with the graphcal mapping. Also I want to know if the written UDF is correct or not.
Even please let me know if my understanding is correct for simple and advanced UDFs - simple - when you need to populate the target field only once.
Advanced when you are populating the target field several times????
Please find the below sample code for UDF which I have written
for(int i=0;i<PaymentMethod.length;i++)
{
if(PaymentMethod[i].equals("Y")&&CompanyCode[i].startsWith("XX"))
{
result.addValue(":23E:TRE");
result.addContextChange();
}
else if (PaymentMethod[i].equals("W")&&Bank[i].startsWith("ING")&&CompanyCode[i].equals("AB29"))
{
result.addValue(":23E:PRGE");
result.addContextChange();
}
else if(PaymentMethod[i].equals("W")||PaymentMethod[i].equals("F")||PaymentMethod[i].equals("I"))
{
result.addValue(":23E:TRE");
result.addContextChange();
}
}
This is working fine but giving an additional null context as shown below.
But when I am trying with the normal graphical there is no last null.... Please let me know how to correctly add the context change so that the additional null will not get added..
Hello,
Remove "result.addContextChange();" from ur code and use splitby value (Each value) function after UDF (if u really want to split values)
BTW, show me ur input queue as well, right click on UDF and show input and output queue.
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,
As already stated lower null was becoz of extra result.addContextChange in ur code which i believe u must have removed. In addition to that, i don't think u need to run any loop becoz by looking ur queues it seems that u will always have 1 single queue in ur context? If yes, then u can remove for loop from ur code.
BTW, don't worry about first null just test ur mapping.
Thanks
Amit Srivastava
Hello,
U can use advanced UDF but no need to loop.
I mean something like this:
Execution type: All values of a context
I am assuming by looking ur queues that there will be only one queue in each context.
if(PaymentMethod[0].equals("Y")&&CompanyCode[0].startsWith("XX"))
{
result.addValue(":23E:TRE");
}
else if (PaymentMethod[0].equals("W")&&Bank[0].startsWith("ING")&&CompanyCode[0].equals("AB29"))
{
result.addValue(":23E:PRGE");
}
else if(PaymentMethod[0].equals("W")||PaymentMethod[0].equals("F")|| PaymentMethod[0].equals("I"))
{
result.addValue(":23E:TRE");
}
Thanks
Amit Srivastava
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.