cancel
Showing results for 
Search instead for 
Did you mean: 

PI Mapping help

former_member229310
Active Participant
0 Kudos
Hello Gurus,


Below is my input XML and need help to generate the output XML via graphical mapping.

INPUT xml :

<Products>
	<Product>
		<MATNR>A</MATNR>
		<Desc>mat1</Desc>
	</Product>
	<Product>
		<MATNR>B</MATNR>
		<Desc>mat2</Desc>
	</Product>
</Products>
<Partner>
	<Customer>
		<NAME>X</NAME>
		<ACTIVE>0</ACTIVE>
	</Customer>
	<Customer>
		 <NAME>Y</NAME>
		<ACTIVE>0</ACTIVE>
	</Customer>
</Partner>

i need to generate every combination of 1product 1customer. Can you help if this is possible in graphical mapping.

OUTPUT XML :


<ActiveCust>
	<Material>
		<MATNR>A</MATNR>
		<Desc>mat1</Desc>
		<NAME>X</NAME>
		<ACTIVE>0</ACTIVE>
	</Material>
	<Material>
		<MATNR>A</MATNR>
		<Desc>mat1</Desc>
		<NAME>Y</NAME>
		<ACTIVE>0</ACTIVE>
	</Material>
	<Material>
		<MATNR>B</MATNR>
		<Desc>mat2</Desc>
		<NAME>X</NAME>
		<ACTIVE>0</ACTIVE>
	</Material>
	<Material>
		<MATNR>B</MATNR>
		<Desc>mat2</Desc>
		<NAME>Y</NAME>
		<ACTIVE>0</ACTIVE>
	</Material>
</ActiveCust>
View Entire Topic
former_member229310
Active Participant
0 Kudos

Hello,

Can you please help with the logic or pseudo code how to proceed.

Thanks.

malathi2608
Explorer
0 Kudos

Hi

you have to play with the context here.

just try as below

1.For parent node "Material"-use the UDF1 to create the context as you needed.(input1- product and input2-customer both input should not have context changes)

2. For MATNR/DESC - use UDF1 along with split by value node function.(input1-MATNR/DESC and input2-Name. both the input should have context changes)

3. For Name/Active - use UDF2 along with split by value node function.(input1 - MATNR and Input2- Name/Active. both the input should not have context changes)

UDF1:

public void cal1(String[] var1, ResultList result, String[] var2, Container container) throws StreamTransformationException{

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

for(int j=0;j<var2.length;j++)

result.addValue(var1[i]);

}

UDF2:

public void cal2(String[] var1, ResultList result, String[] var2, Container container) throws StreamTransformationException{

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

for(int j=0;j<var2.length;j++)

result.addValue(var2[j]);

}

Regards,

Malathi