Mastering SAP PI/PO XSLT Mapping & External Definitions for Warehouse Automation Integration

Integrating SAP Extended Warehouse Management (EWM) with external automation and robotics platforms requires precise handling of multi-message mapping wrappers, rigid schema namespaces, and comprehensive payload transformations. This guide walks through resolving standard transformer engine exceptions, mapping complex outbound picking specifications, and configuring External Definitions step-by-step.


Step 1

Diagnosing and Fixing the Transformer Exception

When running operation mapping tests in SAP PO, runtime engine failures often manifest as transformer exceptions. This is typically driven by namespace mismatches between target schemas and multi-message envelope requirements.

SAP PO Operation Mapping Transformer Exception Screen
Figure 1: Initial runtime XSLT transformer exception captured during testing.
Root Cause: Elements inside loops lacked exact qualified namespace declarations matching http://sap.com/xi/XI/SplitAndMerge envelope requirements alongside target schemas.
Step 2

Building the Complete Pick Order XSLT Mapping

To transition from basic inbound putaway structures to advanced outbound pick orders (covering production vs. spare order rules, auto push walls, item sequence lines, and custom batch attributes), apply the following standard-compliant XSLT stylesheet code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge"
    xmlns:p6="http://example.com/ewm/automation"
    exclude-result-prefixes="">
    
    <xsl:variable name="FINAL_USER_ID">testUser</xsl:variable>
    <xsl:variable name="FINAL_USER_KEY">111111</xsl:variable>

    <xsl:template match="/">
        <ns0:Messages>
            <xsl:for-each select="//*[local-name()='_-SCWM_-E1LTORI']">
                <ns0:Message1>
                    <p6:MT_Automation_PickOrder>
                        <Pick_Order_Request>
                            <header>
                                <warehouse_code>9190</warehouse_code>
                                <user_id><xsl:value-of select="$FINAL_USER_ID"/></user_id>
                                <user_key><xsl:value-of select="$FINAL_USER_KEY"/></user_key>
                            </header>
                            <body>
                                <order_list>
                                    <warehouse_code>9190</warehouse_code>
                                    <out_order_code><xsl:value-of select="ancestor::*[local-name()='_-SCWM_-E1LTORH']/*[local-name()='WHO']"/></out_order_code>
                                    <owner_code><xsl:value-of select="*[local-name()='ZSCWM_WES']/*[local-name()='GOODS_OWNER']"/></owner_code>
                                    <order_type><xsl:value-of select="*[local-name()='ZSCWM_WES']/*[local-name()='ORDER_TYPE']"/></order_type>
                                    <is_auto_push_wall>
                                        <xsl:choose>
                                            <xsl:when test="*[local-name()='ZSCWM_WES']/*[local-name()='ORDER_TYPE'] = '21'">1</xsl:when>
                                            <xsl:otherwise>0</xsl:otherwise>
                                        </xsl:choose>
                                    </is_auto_push_wall>
                                    <sku_list>
                                        <item><xsl:value-of select="*[local-name()='TANUM']"/></item>
                                        <sku_code><xsl:value-of select="*[local-name()='MATNR']"/></sku_code>
                                        <amount><xsl:value-of select="*[local-name()='VSOLM']"/></amount>
                                        <sku_level>0</sku_level>
                                        <sub_sort><xsl:value-of select="*[local-name()='ZSCWM_WES']/*[local-name()='SUBTOTE']"/></sub_sort>
                                        <sku_reservation_1><xsl:value-of select="*[local-name()='ALTME']"/></sku_reservation_1>
                                    </sku_list>
                                </order_list>
                            </body>
                        </Pick_Order_Request>
                    </p6:MT_Automation_PickOrder>
                </ns0:Message1>
            </xsl:for-each>
        </ns0:Messages>
    </xsl:template>
</xsl:stylesheet>
Step 3

Resolving External Definition Parsing Errors

When importing XSD schemas into the Enterprise Services Repository (ESR), parser exceptions like "Error when parsing an XML document (XML document structures must start and end within the same entity)" frequently occur due to truncated multi-file references or unclosed entity brackets.

SAP PO ESR External Definition Parsing Error Screen
Figure 2: ESR UI tracking parser exceptions during zip bundle ingestion.

To permanently clear this compilation fault, use a cleanly separated dual-schema package containing `Schema1.xsd` (core structures) and `MainSchema.xsd` (the envelope wrapper).

Core Structure Definition: Schema1.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://example.com/ewm/automation" 
            xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
            xmlns="http://example.com/ewm/automation" 
            elementFormDefault="qualified">

    <xsd:element name="MT_Automation_PickOrder" type="DT_Automation_PickOrder_Request"/>

    <xsd:complexType name="DT_Automation_PickOrder_Request">
        <xsd:sequence>
            <xsd:element name="Pick_Order_Request">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="header">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element name="warehouse_code" type="xsd:string"/>
                                    <xsd:element name="user_id" type="xsd:string"/>
                                    <xsd:element name="user_key" type="xsd:string"/>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="body">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element name="order_list" maxOccurs="unbounded">
                                        <xsd:complexType>
                                            <xsd:sequence>
                                                <xsd:element name="warehouse_code" type="xsd:string"/>
                                                <xsd:element name="out_order_code" type="xsd:string"/>
                                                <xsd:element name="owner_code" type="xsd:string"/>
                                                <xsd:element name="wave_code" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="original_note" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="order_type" type="xsd:string"/>
                                                <xsd:element name="is_waiting" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="is_allow_lack" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="is_allow_pick_lack" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="is_auto_push_wall" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="can_merge" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="container_type" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="is_allow_split" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="priority" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="waybill_code" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="consignee_name" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="consignee_address" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="consignee_phone" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="total_fee" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="payment_fee" type="xsd:string" minOccurs="0"/>
                                                <xsd:element name="sku_list" maxOccurs="unbounded">
                                                    <xsd:complexType>
                                                        <xsd:sequence>
                                                            <xsd:element name="item" type="xsd:string"/>
                                                            <xsd:element name="sku_code" type="xsd:string"/>
                                                            <xsd:element name="sku_id" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="amount" type="xsd:string"/>
                                                            <xsd:element name="sku_level" type="xsd:string"/>
                                                            <xsd:element name="product_batch" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="production_date" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="expiration_date" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="batch_property05" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="batch_property07" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="batch_property08" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="batch_property09" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="batch_property10" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="batch_property11" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="batch_property12" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="sub_sort" type="xsd:string" minOccurs="0"/>
                                                            <xsd:element name="sku_reservation_1" type="xsd:string" minOccurs="0"/>
                                                        </xsd:sequence>
                                                    </xsd:complexType>
                                                </xsd:element>
                                            <xsd:sequence>
                                        <xsd:complexType>
                                    </xsd:element>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Multi-Message Envelope Definition: MainSchema.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://sap.com/xi/XI/SplitAndMerge" 
            xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
            xmlns:p1="http://example.com/ewm/automation" 
            xmlns="http://sap.com/xi/XI/SplitAndMerge">
            
    <xsd:import namespace="http://example.com/ewm/automation" schemaLocation="Schema1.xsd"/>
    
    <xsd:element name="Messages">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Message1" form="qualified">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element ref="p1:MT_Automation_PickOrder" minOccurs="0" maxOccurs="unbounded"/>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>
Deployment Tip: Compress both Schema1.xsd and MainSchema.xsd directly into a flat ZIP archive without inner folders, then upload them into your External Definition via the ESR interface, selecting MainSchema.xsd as the root reference target.