cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Java

Former Member
0 Kudos

Hi!

Can you help me with a Java function.

I want to check if a field exists or not. If it exists then I want to produce an Idoc in the target structure and if it doesn't exist then no Idoc should be produced.

I have "Value of Context" in my UDF and my code looks like this:

for(int i=0;i<PartCode.length;i++)

if (ObjectA<i>.equals("1") && ObjectB.length >= 1)

{

result.addValue(e<i>);

}

else

{

result.addSuppress();

}

Everything works beside the .length function. The Idoc is populated even if ObjectB doesn't exist

Edited by: Sonny Chaos on May 10, 2010 3:18 PM

Accepted Solutions (1)

Accepted Solutions (1)

former_member181962
Active Contributor
0 Kudos

Try this:

for(int i=0;i<PartCode.length;i++)

if (ObjectA.equals("1") && ObjectB.length >= 1)
{
if !(ObjectB.equals(ResultList.SUPPRESS))
{
if !(ObjectB.equals(ResultList.CC))
{
result.addValue(e);
}
}
}
else
{ 
result.addSuppress(); 
}

Former Member
0 Kudos

HI,

Thanks for your solution but I still get the same. The Idoc is still produced even when it shouldn't.

former_member181962
Active Contributor
0 Kudos

What is the queue that you see when you click on ObjectB?

Regards,

Ravi

Former Member
0 Kudos

I don't know if I understood you question but when I click "display queue" then I see the input that is in that field "136270510"

Answers (3)

Answers (3)

former_member181962
Active Contributor
0 Kudos

did you try length() instead of length?

Regards,

ravi

Former Member
0 Kudos

Yes but as I mentioned before I use "Context" and you can't use () for that.

former_member181962
Active Contributor
0 Kudos

WHy do you need a UDF for this?

You can use the Exists function isn't it?

Former Member
0 Kudos

Yes I know but the actual Code is very long and there are more conditions that I didn't mention here. the Graphical Mapping would be very long and complicated.

Shabarish_Nair
Active Contributor
0 Kudos

why cant you use the standard node function EXISTS for your requirement?

Former Member
0 Kudos

Yes I know but the actual Code is very long and there are more conditions that I didn't mention here. the Graphical Mapping would be very long and complicated.

And by the way, When I tried to do the Graphical Mapping I got another error. When the field ObjectA occurs 2 times in the same segment then I get a mapping error. it is 1-Outbounded so it should occur several times if necessary but when I use the function EXIST then I get an error that I should check if the mapping is correct.

Former Member
0 Kudos

Hi Sony,

Looks the problem is your target IDOC root level struccture should be 0..1 (so that when condition shatisfied you can create the target else you can suppress) by default 1..1 occurance you have to change of occurance export the IDOC xsd and modify and re-import the IDOC.

Assume your source structre

T1

-> Object A

-> Object A

Above two times apperaed what you can do

ObjectA->CopyValue(0)->chech kength -> and greated then zerp produce empty node so that you can create the target IDOC node.that mean you are populating the IDOC.

Do not write any UTF..try all the standard UDF... Before that first check your occurance are correct.

I mean now you want based on conditon need to create the IDOC in that case target schema should be 0..1 or 0..unbound if it'segment level you want to check..

Regards,

Venu.