0

We are currently planning on communicating with a partner that is running SAP via Idoc files .xml

We already communicate via .xml but with our schema structure, now I´m trying to modify my .xsd to get data from the Idoc WMTORD which contains a tag EILTORH which contains tags occurs once and one tag EILTORI which occurs many times

My question is which type should I use, I tried to make the two types sequence and all on the same tag, and it doesn´t work

<xsd:element name="E1LTORH" type = "E1LTORHType" minOccurs="0"/>
<xsd:complexType name="E1LTORHType">
    <xsd:sequence maxOccurs="unbounded">
        <xsd:element name="LGNUM" type="xsd:string" minOccurs="0" />
        <xsd:element name="TANUM" type="xsd:string" minOccurs="0" />
        <xsd:element name="E1LTORI" type="E1LTORIType" minOccurs="0" />
    </xsd:sequence>

<xsd:complexType name="E1LTORIType">
<xsd:all maxOccurs="1">
        <xsd:element name="Operation" type="OperationType"minOccurs="0"/>
        <xsd:element name="TAPOS" type="xsd:integer" minOccurs="0" />
        <xsd:element name="MATNR" type="xsd:string" minOccurs="0" />
        <xsd:element name="WERKS" type="xsd:string" minOccurs="0" />
        <xsd:element name="CHARG" type="xsd:string" minOccurs="0" />
        <xsd:element name="MEINS" type="xsd:string" minOccurs="0" />
        <xsd:element name="LETYP" type="xsd:string" minOccurs="0" />
</xsd:all>
<xsd:attribute name="SEGMENT" type="xsd:string" />
</xsd:complexType>

Below an example of the file

<E1LTORH SEGMENT="1">
        <LGNUM>B02</LGNUM>
        <TANUM>0100000024</TANUM>
        <BWLVS>999</BWLVS>
        <TRART>X</TRART>
        <BNAME>GUPET</BNAME>
        <PERNR>00000000</PERNR>
        <SOLWM> 0.000</SOLWM>
        <SOLEX> 0.000</SOLEX>
        <ISTWM> 0.000</ISTWM>
        <STDAT>00000000</STDAT>
        <ENDAT>00000000</ENDAT>
        <STUZT>000000</STUZT>
        <ENUZT>000000</ENUZT>
        <SWABW>0000</SWABW>
        <TAPRI>00</TAPRI>
        <E1LTORI SEGMENT="1">
            <TAPOS>0001</TAPOS>
            <MATNR>ISA46290</MATNR>
            <WERKS>BP02</WERKS>
            <CHARG>L01.01</CHARG>
            <MEINS>ST</MEINS>
            <LETYP>BT1</LETYP>
            <KZQUI>X</KZQUI>
            <WDATU>20181212</WDATU>
            <WENUM>4900002737</WENUM>
            <WEPOS>0001</WEPOS>
            <VLTYP>MEC</VLTYP>
            <VLBER>001</VLBER>
            <VLPLA>TRANSTOCK</VLPLA>
            <VSOLM>10.000</VSOLM>
            <NLTYP>PCO</NLTYP>
            <NLBER>001</NLBER>
            <NLPLA>PCO-B-3A</NLPLA>
            <NSOLM>10.000</NSOLM>
            <MAKTX>Bleomycin complex A2/B2 ISA</MAKTX>
            <NLENR>00000000002000000823</NLENR>
            <QPLOS>000000000000</QPLOS>
            <QPLOA>000000000000</QPLOA>
            <LGORT>ETA2</LGORT>
            <SOLPO> 0.000</SOLPO>
            <VOLUM> 0.000</VOLUM>
            <NPLEI>1</NPLEI>
            <NWIRM> 0.000</NWIRM>
        </E1LTORI>
    </E1LTORH>
Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
  • Hi Mohamed. What do you mean by "it doesn't work". Do you get an error when validating the XML against your schema? Currently your schema looks to be incomplete missing the definition of many fields. Do you want the EILTORI fields to be in sequence, is you've declared them with `` – Dijkgraaf Aug 05 '19 at 00:50

2 Answers2

0

You appear to be missing definition for many fields, below is a full definition that I've generated from your XML (after wrapping a iDOC root node around it, which you can rename).

One of the things you said is that EILTORI occurs many times, but your element EILTORI does not have maxOccurs="unbounded" which I've set.

I've left the definition of the EILTORI type to be xs:all, was not sure if you meant this to be sequence or not from your question.

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="iDOC">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="E1LTORH">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" name="LGNUM" type="xs:string" />
              <xs:element minOccurs="0" name="TANUM" type="xs:string" />
              <xs:element minOccurs="0" name="BWLVS" type="xs:string" />
              <xs:element minOccurs="0" name="TRART" type="xs:string" />
              <xs:element minOccurs="0" name="BNAME" type="xs:string" />
              <xs:element minOccurs="0" name="PERNR" type="xs:string" />
              <xs:element minOccurs="0" name="SOLWM" type="xs:decimal" />
              <xs:element minOccurs="0" name="SOLEX" type="xs:decimal" />
              <xs:element minOccurs="0" name="ISTWM" type="xs:decimal" />
              <xs:element minOccurs="0" name="STDAT" type="xs:string" />
              <xs:element minOccurs="0" name="ENDAT" type="xs:string" />
              <xs:element minOccurs="0" name="STUZT" type="xs:string" />
              <xs:element minOccurs="0" name="ENUZT" type="xs:string" />
              <xs:element minOccurs="0" name="SWABW" type="xs:string" />
              <xs:element minOccurs="0" name="TAPRI" type="xs:string" />
              <xs:element maxOccurs="unbounded" name="E1LTORI" type="E1LTORI" />
            </xs:sequence>
            <xs:attribute name="SEGMENT" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:complexType name="E1LTORI">
    <xs:all minOccurs="1" maxOccurs="1">
      <xs:element minOccurs="0" name="TAPOS" type="xs:string" />
      <xs:element minOccurs="0" name="MATNR" type="xs:string" />
      <xs:element minOccurs="0" name="WERKS" type="xs:string" />
      <xs:element minOccurs="0" name="CHARG" type="xs:string" />
      <xs:element minOccurs="0" name="MEINS" type="xs:string" />
      <xs:element minOccurs="0" name="LETYP" type="xs:string" />
      <xs:element minOccurs="0" name="KZQUI" type="xs:string" />
      <xs:element minOccurs="0" name="WDATU" type="xs:string" />
      <xs:element minOccurs="0" name="WENUM" type="xs:string" />
      <xs:element minOccurs="0" name="WEPOS" type="xs:string" />
      <xs:element minOccurs="0" name="VLTYP" type="xs:string" />
      <xs:element minOccurs="0" name="VLBER" type="xs:string" />
      <xs:element minOccurs="0" name="VLPLA" type="xs:string" />
      <xs:element minOccurs="0" name="VSOLM" type="xs:decimal" />
      <xs:element minOccurs="0" name="NLTYP" type="xs:string" />
      <xs:element minOccurs="0" name="NLBER" type="xs:string" />
      <xs:element minOccurs="0" name="NLPLA" type="xs:string" />
      <xs:element minOccurs="0" name="NSOLM" type="xs:decimal" />
      <xs:element minOccurs="0" name="MAKTX" type="xs:string" />
      <xs:element minOccurs="0" name="NLENR" type="xs:string" />
      <xs:element minOccurs="0" name="QPLOS" type="xs:string" />
      <xs:element minOccurs="0" name="QPLOA" type="xs:string" />
      <xs:element minOccurs="0" name="LGORT" type="xs:string" />
      <xs:element minOccurs="0" name="SOLPO" type="xs:decimal" />
      <xs:element minOccurs="0" name="VOLUM" type="xs:decimal" />
      <xs:element minOccurs="0" name="NPLEI" type="xs:integer" />
      <xs:element minOccurs="0" name="NWIRM" type="xs:decimal" />
    </xs:all>
    <xs:attribute name="SEGMENT" type="xs:string" use="required" />
  </xs:complexType>
</xs:schema>
Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
0

Ideally you would not create the XML Schema yourself, but build on the existing XML Schema definition, which the SAP system of your partner provides.

Given that your partner has correctly maintained his system, you should be able to fetch the XML Schema definition from transaction WE60.

  • Open WE60
  • Enter the IDoc basic type (and optionally enhancements), for which you would like to export the XML Schema
  • Select menu item Documentation > XML Schema

I wrote a more detailed explanation on how to do that some time ago, in case you are interested in a step-by-step guide with screenshots: https://ecosio.com/en/blog/what-is-the-sap-idoc-format/

Philipp

Integration Engineering @ ecosio

Philipp
  • 538
  • 6
  • 14