cancel
Showing results for 
Search instead for 
Did you mean: 

UDF query for IDoc to File mappng

r_s_kulkarni11
Participant
0 Kudos

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..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

r_s_kulkarni11
Participant
0 Kudos

Hi Amit,

Please find the input queue

r_s_kulkarni11
Participant
0 Kudos

Hi Amit,

I think now it works correctly, the lower null is now removed but the upper null is still there.

Is there any issue with my loop?

Also can you throw some light on my other questions?

Thanks in advance.

Former Member
0 Kudos

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

r_s_kulkarni11
Participant
0 Kudos

Hi Amit,

Thanks for the update, but do you want to say that I should use simple UDF instead of the advanced UDF. Because removing a loop means I need to remove the queue context and single string value? Becasue removing a loop will give me an error in current UDF right?

Former Member
0 Kudos

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

Answers (0)