Problem with UDF context changes
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
Former Member replied
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