cancel
Showing results for 
Search instead for 
Did you mean: 

Error in UseOneAsMany Function Error in SAP XI

former_member331856
Participant
0 Kudos

Error in UseOneAsMany Function Error in SAP XI

Hi Experts,

I am trying the Example of function UseOneAsMany. My Input and Output XML Files are provided below:
<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_MM4 xmlns:ns0="http://test/mapping.test">
   <Header>
      <MatNo>MatNo</MatNo>
      <MatDesc>MatDesc</MatDesc>
   </Header>
   <Item>
      <MatNo>MatNo1</MatNo>
      <ItemNo>ItemNo1</ItemNo>
      <MatGroup>MatGroup1</MatGroup>
      <Mattype>Mattype1</Mattype>
      <Plant>Plant1</Plant>
   </Item>
   <Item>
      <MatNo>MatNo2</MatNo>
      <ItemNo>ItemNo2</ItemNo>
      <MatGroup>MatGroup2</MatGroup>
      <Mattype>Mattype2</Mattype>
      <Plant>Plant2</Plant>
   </Item>
</ns0:MT_MM4>

My Expected Output should be :


<?xml version="1.0" encoding="UTF-8"?>
-<ns0:MT_MM4R xmlns:ns0="http://test/mapping.test">
-<Header>
<MatNo>MatNo</MatNo>
<MatDesc>MatDesc</MatDesc>
<MatGroup>MatGroup1</MatGroup>
</Header>
-<Item>
<MatNo>MatNo1</MatNo>
<ItemNo>ItemNo1</ItemNo>
<Mattype>Mattype1</Mattype>
<Plant>Plant1</Plant>
</Item>
-<Header>
<MatNo>MatNo</MatNo>
<MatDesc>MatDesc</MatDesc>
<MatGroup>MatGroup2</MatGroup>
</Header>
-<Item>
<MatNo>MatNo2</MatNo>
<ItemNo>ItemNo2</ItemNo>
<Mattype>Mattype2</Mattype>
<Plant>Plant2</Plant>
</Item>
</ns0:MT_MM4R>

But for me Headers are coming first and then followed by two items. Please let me know how to solve the issue and also please provide the explanation.

Thanks,
GIRIDHAR


Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Change ur structure little bit (add parent node "Record") and then use java mapping pasted in below blog to remove Record node to get ur desired structure.

<?xml version="1.0" encoding="UTF-8"?>

-<ns0:MT_MM4R xmlns:ns0="http://test/mapping.test">

<Record> --- 0..Unbounded

-<Header>

<MatNo>MatNo</MatNo>

<MatDesc>MatDesc</MatDesc>

<MatGroup>MatGroup1</MatGroup>

</Header>

-<Item>  

<MatNo>MatNo1</MatNo>

<ItemNo>ItemNo1</ItemNo>

<Mattype>Mattype1</Mattype>

<Plant>Plant1</Plant>

</Item>

</Record>

<Record>

-<Header>

<MatNo>MatNo</MatNo>

<MatDesc>MatDesc</MatDesc>

<MatGroup>MatGroup2</MatGroup>

</Header>

-<Item>

<MatNo>MatNo2</MatNo>

<ItemNo>ItemNo2</ItemNo>

<Mattype>Mattype2</Mattype>

<Plant>Plant2</Plant>

</Item>

</Record>

</ns0:MT_MM4R>

Thanks

Amit Srivastava

Answers (2)

Answers (2)

Harish
Active Contributor
0 Kudos

Hi Giri,

your output and expected output structure is not same. MatGroup is not present in your output structure.

Please check your output structure.

regards,

Harish

former_member331856
Participant
0 Kudos


Hi Harish,


My Expected Output should be like this.

<?xml version="1.0" encoding="UTF-8"?>
-<ns0:MT_MM4R xmlns:ns0="http://test/mapping.test">
-<Header>
<MatNo>MatNo</MatNo>
<MatDesc>MatDesc</MatDesc>
</Header>
-<Item>
<MatNo>MatNo1</MatNo>
<ItemNo>ItemNo1</ItemNo>
<Mattype>Mattype1</Mattype>
<Plant>Plant1</Plant>
</Item>
-<Header>
<MatNo>MatNo</MatNo>
<MatDesc>MatDesc</MatDesc>
</Header>
-<Item>
<MatNo>MatNo2</MatNo>
<ItemNo>ItemNo2</ItemNo>
<Mattype>Mattype2</Mattype>
<Plant>Plant2</Plant>
</Item>
</ns0:MT_MM4R>

Regards,
GIRIDHAR

Harish
Active Contributor
0 Kudos

Hi Giri,

you can not change the position of header using graphical mapping if they are in same level.

You need to use XSLT or Java map to chagne the position.

But why you want second header to come after item/items. I think it is better to change the output structure and place item under the header segment.

regards,

Harish

former_member184720
Active Contributor
0 Kudos

Hi Giri - Both Header and Item are under same level?

former_member331856
Participant
0 Kudos

Hi Hareesh,

Yes, both the Header and Iteam are in same level.

Regards,

GIRIDHAR

former_member184720
Active Contributor
0 Kudos

Unless you go with the XSLT, it's not possible.

If you want to group them, item should be under header.. If you are doing it for testing/example then create a nested structure and try with graphical mapping..