cancel
Showing results for 
Search instead for 
Did you mean: 

graphical mapping problem

former_member745782
Active Participant
0 Kudos

hello everybody

i'm crating a new message mapping (graphical).

I have a very easy Data Type structure, and i need split the result when the input field F1 have a value 001 (creating a new context).

I think is very easy but i cannot find the correct solution

this is the input:

<RECORDS>

<R10>

<F1>001</F1>

<F2>DT:13.03.11/23:08:45</F2>

</R10>

<R10>

<F1>002</F1>

<F2>NR:111879</F2>

</R10>

<R10>

<F1>003</F1>

<F2>NR:1</F2>

</R10>

<R10>

<F1>004</F1>

<F2>NR:1</F2>

</R10>

<R10>

<F1>001</F1>

<F2>DT:13.03.11/23:08:46</F2>

</R10>

<R10>

<F1>002</F1>

<F2>NR:111880</F2>

</R10>

</RECORDS>

and this is output:

<RECORDS>

<RECORD>

<R10>

<F1>001</F1>

<F2>DT:13.03.11/23:08:45</F2>

</R10>

<R10>

<F1>002</F1>

<F2>NR:111879</F2>

</R10>

<R10>

<F1>003</F1>

<F2>NR:1</F2>

</R10>

<R10>

<F1>004</F1>

<F2>NR:1</F2>

</R10>

</RECORD>

<RECORD>

<R10>

<F1>001</F1>

<F2>DT:13.03.11/23:08:46</F2>

</R10>

<R10>

<F1>002</F1>

<F2>NR:111880</F2>

</R10>

</RECORD>

</RECORDS>

Accepted Solutions (1)

Accepted Solutions (1)

RKothari
Contributor
0 Kudos

Hello,

Try the below UDF.

Input the values of F1 field in a single context.

int i;
for(i=0;i<F1.length;i++)
{
	if(i==0 && F1<i>.equals("001")
	{
		result.addValue(F<i>);
	}
	else
	{
		if(F<i>.equals("001"))
		{
			result.addContextChange();
			result.addValue(F1<i>);
		}
		else
		{
			result.addValue(F1<i>);
		}
		
	}
}

-Rahul

former_member745782
Active Participant
0 Kudos

thanks Rahul!

and the Result? where i need map it?

to RECORD?

RKothari
Contributor
0 Kudos

Hello,

Yes, please use the udf to map it at Record node. As it seems by the output structure that new Record node is created when F1 field has new 001 value.

-Rahul

former_member745782
Active Participant
0 Kudos

hi Rahoul,

thanks a lot for help

ok i dit it

but i have 2 problems:

1 - with your function i have always N-1 Record. Example if i have 8 F1 fields with value 001, on ouput i have only 7 Record.

2 - how i need map the field under Record? R10 and F1 and F2

RKothari
Contributor
0 Kudos

Hi,

Please try using CollapseContext Node function after UDF for Record Node.

For fields under Record Node it will be direct mapping.

Regards,

Rahul

former_member745782
Active Participant
0 Kudos

thanks Rahul!

now the number of RECORD is correct , but fields under no.

I have all R10 records under the first RECORD. The same for F1 and F2

I tried to change context of fields but without result

RKothari
Contributor
0 Kudos

Hi,

Try using output of UDF directly for R10(without collapse context).

For F1 and F2 keep context on R10 or use splitByValue(Each).

-Rahul

former_member745782
Active Participant
0 Kudos

super!!!

now work

thanks so much!

Answers (2)

Answers (2)

former_member745782
Active Participant
0 Kudos

more difficult

former_member745782
Active Participant
0 Kudos

hello again...

i'm still working with this interface and something changed.

so the input data change as follow:

the record <RECORDS> have not occurrences 1-1 but 1-umbounded.

So a example of input can be like this:

<TABLE>
     <RECORDS>
	<R10>
		<F1>001</F1>
		<F2>position 1-1</F2>
	</R10>
	<R10>
		<F1>002</F1>
		<F2>NR:111879</F2>
	</R10>
	<R10>
		<F1>001</F1>
		<F2>*position 1-2*</F2>
	</R10>
	<R10>
		<F1>002</F1>
		<F2>*NR:111880*</F2>
	</R10>
    </RECORDS>
    <RECORDS>
	<R10>
		<F1>001</F1>
		<F2>*position 2-1*</F2>
	</R10>
	<R10>
		<F1>002</F1>
		<F2>NR:111879</F2>
	</R10>
    </RECORDS>
</TABLE>

my problem is that in my output i found all fields inside <RECORD> under the first <RECORDS>.

(like this)

<TABLE>
   <RECORDS>
	<RECORD>
         	(*position 1-1*)
	</RECORD>
	<RECORD>
         	(position 1-2)
	</RECORD>

	<RECORD>
     	        (*position 2-1*)
	</RECORD>


   </RECORDS>

   <RECORDS>
                (empty)
   </RECORDS>

</TABLE>

i tried to change context but no good result. So this function seems work only when i have only one <RECORDS> in my file.

Maybe i need change UDF?

Or map in different mode <RECORD>

I hope explained me clearly.

Any suggestion will be appreciated. Thanks

Alex

Edited by: apederiva on May 20, 2011 2:53 PM

Edited by: apederiva on May 20, 2011 2:54 PM

Former Member
0 Kudos

hi,

did you try to put in removecontexts in front of the udf?

former_member745782
Active Participant
0 Kudos

i tried but nothing change. I already map F1 field with higther context so it's the same.

After UDF i have a collapseContext function. Using this the mapping work but only with one <RECORDS>

Former Member
0 Kudos

try this:

1) Records ---> Records

2) F1 (set its context to Records)-UDF-Record

UDF:


for(int i=0;i<a.length;i++)
{
if(a<i>.equals("001"))
{
result.addValue(a<i>);
}
}

Rest all will be same..

former_member463616
Contributor
0 Kudos

Hi,

Create Duplicate subtree at receiver side for the node RECORD, and map one to one mapping.

Hope this helps.

Regards,

P.Rajesh

former_member745782
Active Participant
0 Kudos

i cannot duplicate subtree because i can have 1-n RECORD

Former Member
0 Kudos

int z=0;

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

{

if(a[ i ].equals("001")) (put i under square brackets)

{

z=z+1;

if(z>=1)

{

result.addContextChange();

z=0;

}

result.addValue(a[ i ]); (put i under square brackets)

}

else

{

result.addValue(a[ i ]); (put i under square brackets)

}

}