Вы находитесь на странице: 1из 11

Exercise 3: Advanced Message Mapping Overview The purpose of this exercise is to design a Message Mapping utilizing advanced user

functions along with the standard XI 3.0 functions. Some basic knowledge of Java will be required. This exercise will test the understanding of context/queue processing of Message Mapping. Prerequisites Advanced knowledge of XI 3.0 Message Mapping. Basic knowledge of Java. Description The source is an XML document containing purchase order information. This document contains a single header with multiple detailed purchase orders. In each detailed purchase order, the suppliers name is provided. There can be more than 1 detailed purchase order per supplier, and the number of suppliers is unknown. The detailed purchase orders are not grouped by supplier, in another word, it is not sorted by supplier name. The result of the mapping/transformation will contain an order for each supplier. Each supplier will contain the header information from the source, and all the detailed purchase orders belonging to the same supplier must be grouped within the order. For example, the source contains 2 suppliers and 4 detailed purchase orders. The 2 nd and 3rd detailed purchase orders belong to companyA, and the 1 st and 4th detailed purchase orders belong to companyB. The result of the mapping/transformation must contain 2 orders, each with a header. For companyAs order, it must contain the 2 nd and 3rd detailed purchase orders. For companyBs order, it must contain the 1st and 4th detailed purchase orders. Example source XML: <?xml version="1.0" encoding="UTF-8"?> <ns9:POCombined xmlns:ns9="http://sap.com/xi30/mapping/patterns"> <Header> <Name>myName</Name> <Address>myAddress</Address> </Header> <Detail> <Supplier>OfficeMax</Supplier> <ProductID>11</ProductID> <Quantity>12</Quantity> <Price>13</Price> </Detail> <Detail> <Supplier>OfficeDepot</Supplier> <ProductID>21</ProductID> <Quantity>22</Quantity> <Price>23</Price> </Detail> <Detail> <Supplier>OfficeDepot</Supplier> <ProductID>31</ProductID> <Quantity>32</Quantity> <Price>33</Price>

</Detail> <Detail> <Supplier>OfficeMax</Supplier> <ProductID>42</ProductID> <Quantity>42</Quantity> <Price>43</Price> </Detail> </ns9:POCombined> Result of the mapping/transformation: <?xml version="1.0" encoding="UTF-8"?> <ns9:POSplit xmlns:ns9="http://sap.com/xi30/mapping/patterns"> <Orders> <Header> <toCompany>OfficeMax</toCompany> <custName>myName</custName> <custAddress>myAddress</custAddress> </Header> <Items> <productNo>11</productNo> <quantity>12</quantity> <price>13</price> </Items> <Items> <productNo>42</productNo> <quantity>42</quantity> <price>43</price> </Items> </Orders> <Orders> <Header> <toCompany>OfficeDepot</toCompany> <custName>myName</custName> <custAddress>myAddress</custAddress> </Header> <Items> <productNo>21</productNo> <quantity>22</quantity> <price>23</price> </Items> <Items> <productNo>31</productNo> <quantity>32</quantity> <price>33</price> </Items> </Orders> </ns9:POSplit> Exercise steps *Please note, as a general rule, all development and configuration objects, especially Java codes, in XI are CASE-SENSITIVE.

There are many ways to achieve the desired result. The solution provided here is only 1 way, not the only way. Create a Message Mapping 1. Logon to Integration Repository. 2. Go into SWCV and namespace. 3. Create a Message Mapping object. Use any name you wish. 4. Use Search Repository Object to import the source and target message.


Go to: <SWCV> <namespace> External Definitions MappingPatterns POCombined (for source) / POSplit (for target)

6. The result should look like the following:

7. To achieve the mapping requirement, we need to do the following: a. Determine the number of unique suppliers. This is how many Orders we must create in the target. b. Assign the Header information to each of the Orders in the target. c. Determine the number items for each supplier. d. Assign the Detail information to the Items to the appropriate supplier in the target. 8. Create the following 4 Advanced User Functions: getSuppliers using Supplier as the input parameter, this function tests all the Supplier values and return only the unique ones.

assignItems using Supplier as the input parameter, this function determines how many Items belongs to each Supplier and separate them with a ContextChange. In another word, for each Supplier, it create the number of Items element for it.

assignValue using the number of unique Supplier as input, that same number of the value in the 2nd parameter will be added to the output. So, if there are 2 Suppliers, then the value in the 2nd parameter will be copied 2 times.

assignSupplier this function is to assign the elements in Detail to the appropriate Items of a Suppliers Order. It is used to rearrange/reorder the elements in Detail corresponding to how the Items are grouped together based on the Supplier.

9. Create the following mappings in the Data Flow Editor:

Please note that all italicized source element name has context of POCombined.

10. Test the mapping by using the Test tab. Enter the following data as an example.

The result should be the following: