cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with UDF context changes

Former Member
0 Kudos

Hi experts,

i am facing a slight problem with my UDF:

the scenario is idoc to jdbc, my problem is as follow:

in my source I have:

IDOC

>E1EDKA1 1..1

>>NAME1 1..1

>E1EDP01 1..999

>>E1EDPA1 1..999

>>>PARVW 1..999

>>>NAME1 1..999

in my target i create as many segments than there is E1EDP01

The problem is for each E1EDP01 I have several E1EDPA1 that itself contains several times the couple PARVW and NAME1.

And my condition is as follow: in E1EDPA1, I have to take the value of NAME1 for PARVW = YZ or XZ, and the value of NAME1 in E1EDPKA1 if i dont find YZ or XZ in E1EDPA1

My udf works when in each segment it is true, but does not work when in one segment the condition is missing:

for example, I have:

IDOC

>E1EDKA1

>>NAME1=name_header

>E1EDP01

>>E1EDPA1

>>>PARVW = AB

>>>NAME1 = name_AB

>>>PARVW = AC

>>>NAME1 = name_AB

>>>PARVW = YZ

>>>NAME1 = name_YZ1

>E1EDP01

>>E1EDPA1

>>>PARVW = AD

>>>NAME1 = name_AD

>>>PARVW = AE

>>>NAME1 = name_AE

>>>PARVW = XZ

>>>NAME1 = name_XZ1

in my target I must have:

statementName

>statement_name

>>action

>>table

>>access

>>>field_name = name_YZ1

statementName

>statement_name

>>action

>>table

>>access

>>>field_name = name_XZ1

I manage to get the result with the following UDF


for (int i = 0; i < PARVW.length; i++) {
			if (("YZ".equals(PARVW<i>.trim()))){
				result.addValue(NAME_poste<i>);
				
			}
			else if (("XZ".equals(PARVW<i>.trim()))){
				result.addValue(NAME_poste<i>);
				
			}
			//else {
				
				//result.addValue(NAME_header[0]);
			//}
		}

but as soon as i uncomment the else part (in order to get the value of NAME1 in the header part when PARVW is not equal to XY or XZ), it does not work.

another example is :

IDOC

>E1EDKA1

>>NAME1=name_header

>E1EDP01

>>E1EDPA1

>>>PARVW = AB

>>>NAME1 = name_AB

>>>PARVW = AC

>>>NAME1 = name_AB

>>>PARVW = YZ

>>>NAME1 = name_YZ1

>E1EDP01

>>E1EDPA1

>>>PARVW = AD

>>>NAME1 = name_AD

>>>PARVW = AE

>>>NAME1 = name_AE

then I must have:

statementName

>statement_name

>>action

>>table

>>access

>>>field_name = name_YZ1

statementName

>statement_name

>>action

>>table

>>access

>>>field_name = name_header

hope I've been clear enough, any help will be rewarded,

thanks a lot,

Jamal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

try this..



int i = 0;
boolean found = false;
for ( ; i < PARVW.length; i++) 
{
			if (("YZ".equals(PARVW<i>.trim())) || ("XZ".equals(PARVW<i>.trim()) ) )
                        {
                           found = true;
                           break;
                        }

}

if ( found )
{
  result.addValue(NAME_poste<i>);
}
else
{
  result.addValue(NAME_header[ 0] );
}

Edited by: Anand on Oct 14, 2008 7:08 PM

Answers (3)

Answers (3)

Former Member
0 Kudos

Yes it is like this, E1EDPA1 can appear several times with PARVW and NAME1 different.

The problem is solved though thanks to Anand, it works perfectly fine thanks to his UDF!!!

THANKS again friends,

kind regards,

Jamal

Former Member
0 Kudos

E1EDPA1 1..999

PARVW 1..999

NAME1 1..999

The problem is for each E1EDP01 I have several E1EDPA1 that itself contains several times the couple PARVW and NAME1.

Are you sure it is like this ?

Usually the PARVW and NAME1 will appear only once in each occurence of E1EDPA1 and there will be multiple E!EDPA1 for each partner function.

regards,

Advait

Former Member
0 Kudos

Hi,

thx for your help, the problem is that I get only one value as output

regards,

jamal

Former Member
0 Kudos

you didnt change the context of PARVW element right..and the value should be context when u defined as parameter

Former Member
0 Kudos

values of queue PARVW as per second example should have

AB, AC, YZ, ContextChange, AD, AE ....so it should be 2 values right?