符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
Composition and Structure of an INVOIC IDoc in SAP ERP
创新互联专注于磐石企业网站建设,成都响应式网站建设公司,商城系统网站开发。磐石网站建设公司,为磐石等地区提供建站服务。全流程按需定制网站,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务
https://ecosio.com/en/blog/2019/03/29/Composition-and-Structure-of-a-INVOIC-IDoc-in-SAP-ERP/
The exchange of electronic invoices when using an SAP ERP system is done using the INVOIC message type. In this article we demonstrate the structure of an INVOIC IDoc and take a closer look at the specifics, especially how the invoice data is represented in an IDoc.
Motivation for IDocs
is the short form of Intermediate Document . As the word intermediate suggests, it is an intermediate format, for the data exchange with an SAP ERP system. Using IDocs, a third-party system is able to export and import data from and to an SAP ERP system. This data might originate from systems containing master data such as debtor data, creditor data, material master records etc. Other examples include dynamic data records such as timesheets, orders or invoices.
The SAP ERP system delivers a wide range of predefined IDoc base types, which can be used for data exchange. These predefined IDocs may not fully satisfy all requirements, in which case new IDoc types can be created, exactly meeting specific customer requirements.
Understanding the IDoc Contents
In order to be able to read the contents of an IDoc, the first step is to understand its structure. Unlike other XML-based standards, Universal Business Language (UBL) for example, IDocs use short and at first sight, incomprehensible element names. One will not be able to understand them without a supporting document that explains what these abbreviations mean. As the experience with IDocs increases, the abbreviated element names will become more familiar and their meaning will unfold - even without the documentation constantly at hand.
An IDoc can exist in different forms, but usually an IDoc can be found as database entry in an SAP system, where the following tables are being used: EDIDC , EDID4 , EDIDS . The EDIDC table contains the data of the control record, the EDID4 table for the data records, and the EDIDS table for the status records. Transaction SE16N may be used to take a closer look at these tables.
However, users normally use their specific transactions to view IDocs, for example transaction BD87. The picture below shows a tree representation of an INVOIC02 IDoc in transaction BD87.
Tree view of an INVOIC02 IDoc (click for a bigger picture)
As one can see on the left side of this picture, IDocs use abbreviations to name each element, E1EDK01, E1EDKA1, etc.
To check what these elements mean, the documentation of the corresponding IDoc base type must be used, which can be found in transaction WE60. This explains the details in regard to the IDoc documentation.
The IDoc documentation can be downloaded as HTML file and displayed in any Web browser. The SAP ERP system always exports three data types, ending with _d, _f and _i. In order to get the best representation of the data, we recommend opening the file ending with _f, e.g., INVOIC02_f.htm. Below is an extract from the HTML documentation for an INVOIC02 IDoc.
Extract of an INVOIC02 documentation
With help from the HTML documentation, each element can easily be deciphered and the exact sequence the elements are in can be identified.
When an IDoc leaves the SAP system, an exchange file is created using the data in the IDoc tables. This exchange file comes in two formats: a text-based version and an XML-based version. Modern integration scenarios typically use the XML-based version only.
An Overview of the INVOIC02 IDoc
XML knows two fundamental concepts: XML Schema and XML instance. An XML instance is a concrete form of an IDoc, for example the XML representation of the invoice with the number 4711. An XML Schema describes the exact structure and composition of an XML instance. It defines which element and attribute sequences are allowed, which data types can be used for some elements, etc.
The following figure shows an extract of the composition of an INVOIC02 XML Schema.
XML Schema of an INVOIC02 IDoc (click for a bigger version)
With the help of an XML Schema one can check if the XML instance fulfills the requirement of schema conformity and is thus valid or not. Schema conformity is imperative if an INVOIC02 invoice shall be processed using software.
INVOIC02 IDoc in Detail
An INVOIC02 can be used in various SAP modules, e.g., on the sales and distribution side (to represent an invoice that needs to be sent to a client) or on the materials management side (to represent an invoice that is received from a supplier). Invoices also play an important part in the finance module of SAP, where the actual accounting of the invoice takes place.
Using the data below as an example, we demonstrate the different elements of an INVOIC02 IDoc.
INVOIC02 Data Example
The structure of the INVOIC02 IDoc is built below the central root node INVOIC02. The following extract shows the composition of an INVOIC02 in a shorter version.
...
...
...
...
The complete example XML is accessible via the . The example does not claim integrity of content, meaning that the structure and sequence of elements and attributes are correct. Content and values like sums, taxes, transport information are fictitious though, and show no continuous consistency throughout the file.
The composition of an IDoc can be divided into three large sections:
· Control record
· Data records
· Status records
When exporting an IDoc from an SAP ERP system, only the control record and data records are being exported. Since the status record normally contains internal information from the system about the processing status, it is usually not exported.
The composition of the tree structure of an INVOIC02 IDoc is as follows:
· INVOIC02
· IDOC
· EDI_DC40 – Control Record
· E1EDK01 - Document Header General Data
· E1EDKA1 - Document Header Partner Information
· E1EDK02 - Document Header Reference Data
· E1EDK03 - Document Header Date Segment
· E1EDK05 - Document Header Conditions
· E1EDK04 - Document Header Taxes
· E1EDK17 - Document Header Terms of Delivery
· E1EDK18 - Document Header Terms of Payment
· E1EDK23 - Document Header Currency Segment
· E1EDK28 - Document Header Bank Data
· E1EDK29 - Document Header General Foreign Trade Data
· E1EDKT1 - Document Header Text Identification
· E1EDKT2 - Document Header Texts
· E1EDK14 - Document Header Organizational Data
· E1EDP01 - Document Item General Data
· E1EDP02 - Document Item Reference Data
· E1EDP03 - Document Item Date Segment
· E1EDP19 - Document Item Object Identification
· E1EDP26 - Document Item Amount Segment
· E1EDPA1 - Document Item Partner Information
· E1EDP05 - Document Item Conditions
· E1EDP04 - Document Item Taxes
· E1EDP28 - Document Item - General Foreign Trade Data
· E1EDP08 - Package Data Individual
· E1EDP30 - Document Item Account Assignment Intercompany Billing
· E1EDPT1 - Document Item Text Identification
· E1EDPT2 - Document Item Texts
· E1EDS01 - Summary Segment General
EDI_DC40 - Control Record
The control record EDI_DC40 contains meta information about the IDoc itself (sender, receiver, type of IDoc, etc.) and is mostly relevant for the correct processing of the IDoc message by third-party services. Using the control record, third-party services such as EDI providers are able to identify the sender and receiver of the IDoc, the exact IDoc type and date, etc.
Data Records
After the control record, there are data records, which contain all the data about the invoice. The data records themselves are divided into the header and the line item. Elements which have a K in their name belong to the header data, those with a P belong to the line item data. Elements with an S belong to the sum data.
E1EDK01 - Document Header General Data
The E1EDK01 invoice header contains general data of the invoice, such as currency, UID number of the biller and invoice recipient, weight etc.
The element E1EDK01 can only be present once in an INVOIC02 IDoc.
E1EDKA1 - Document Header Partner Information
The E1EDK01 element is followed by several invoice headers of type E1EDKA1, containing partner information about the customer, biller, goods receiver etc. The PARVW element (partner function) identifies the type of partner.
RS for example stands for invoice issuer. The complete list of the allowed partner roles can be viewed in the IDoc documentation in transaction WE60.
The element E1EDKA1 is optional and can be found up to 99 times in an INVOIC02 IDoc.
E1EDK02 - Document Header Reference Data
In the header E1EDK02 the reference data of the invoice is found. To identify the type of partner, the element QUALF (qualifier reference document) must be examined.
In the example above, the following documents are being referred to:
· Invoice number (009)
· Customer Purchase Order (001)
· Order number of the supplier (002)
The element E1EDK02 is optional and can be found up to 20 times in an INVOIC02 IDoc.
E1EDK03 - Document Header Date Segment
After the reference data, different date values are provided using the element E1EDK03. The IDDAT element (qualifier date segment) allows to identify what type of date is provided.
The example above contains the following date values:
· Billing date for billing index and printout (026)
· Delivery date from the supplier (001)
· Purchase order date (022)
The element E1EDK03 is optional and can be found up to 20 times in an INVOIC02 IDoc.
E1EDK05 - Document Header Conditions
This element lists the individual condition types of an invoice, depending on which condition records are stored in the invoice at header level in SAP.
+ in the ALCKZ element indicates a surcharge and - a deduction. The other elements are as follows:
KSCHL - Condition type (coded)
KOTXT - Condition text
BETRG - Fixed surcharge/discount on total gross
KRATE - Condition record per unit
KPERC- Condition percentage rate
MWSKZ - VAT indicator
KOEIN - Currency
The element E1EDK05 is optional and can be found up to 99 times in an INVOIC02 IDoc.
E1EDK04 - Document Header Taxes
The information pertaining to the taxes specified in the invoice can be found in element E1EDK04.
The VAT abbreviation MWSKZ stands for the VAT indicator. The element MSATZ indicates the VAT rate and MWSBT the value added tax amount.
The element E1EDK04 is optional and can be found up to 999 times in an INVOIC02 IDoc.
E1EDK17 - Document Header Terms of Delivery
Element E1EDK17 indicates the delivery terms of the invoice.
The element QUALF indicates whether it is Incoterms 1 or Incoterms 2. The delivery condition code can be retrieved from the LKOND element and the delivery condition text from the element LKTEXT.
The element E1EDK17 is optional and can be found up to 10 times in the INVOIC02 IDoc.
E1EDK18 - Document Header Terms of Payment
This element contains information about the payment conditions of the invoice.
In the example above, the invoice needs to be paid within 14 days without deductions. Should the invoice be paid right away, a 2% discount can be deducted.
The element E1EDK18 is optional and can be found up to 10 times in an INVOIC02 IDoc.
E1EDK23 - Document Header Currency Segment
This element is used to specify the currency information of the invoice.
The qualifier 001 indicates that the currency mentioned above is the document currency.
The element E1EDK23 is optional and can be found up to 4 times in an INVOIC02 IDoc.
E1EDK28 - Document Header Bank Data
All bank data which are relevant for the invoice, such as IBAN, BIC, bank name, etc. will be mentioned in element E1EDK28.
The element E1EDK28 is optional and can be found up to 20 times in an INVOIC02 IDoc.
E1EDK29 - Document Header General Foreign Trade Data
Data in regard to foreign trade is shown in element E1EDK29 of the invoice.
The IDoc documentation describes which values are allowed in each field. For example, the value table for EXNUM is EIKP and the one for ALAND is table T005. Transaction SE16 or SE16N allows to find out what the values of this table are.
The element E1EDK29 is optional and can be found up to 20 times in an INVOIC02 IDoc.
E1EDKT1 - Document Header Text Identification
This element specifies the header texts from the SAP document in an IDoc and has the sub element E1EDKT2. The qualifier TDID identifies what type of text is provided.
The text language is specified with the TSSPRAS and the TSSPRAS_ISO key. The sub element E1EDKT2 is used for the actual text.
The element E1EDKT1 is optional and can be found up to 20 times in an INVOIC02 IDoc.
E1EDKT2 - Document Header Texts
The sub element E1EDKT2 contains the actual text information in different text lines. The maximum length of a text line TDLINE is 70 characters, longer texts are therefore divided in several TDLINE elements.
The element E1EDKT2 is optional and can be found up to 999 times in an INVOIC02 IDoc.
E1EDK14 - Document Header Organizational Data
SAP relevant organization data such as sales organization or distribution channel are contained in element E1EDK14. The element QUALF (qualifier organization) helps to identify what type of organization data is provided.
The example above shows the following organization data:
· Sales organization (008)
· Distribution channel (007)
· Division (006)
The element E1EDK14 is optional and can be found up to 10 times in the INVOIC02 IDoc. The header finishes with the element E1EDK14 and the line items of the invoice start.
E1EDP01 - Document Item General Data
This element contains the general data of the line items and other sub elements.
The most important elements on the first level are:
...
These elements have the following meaning.
POSEX - Item number. Line items are numbered consecutively. The sequence of the entries (e.g. in 10s or 100s) can be customized in SAP. In most cases POSEX entries have leading zeros.
MENGE - Quantity
MENEE - Unit of measure
NETGEW - Net weight of the line item
GEWEI - Weight unit
BRGEW - Total weight of the line item
PSTYV - Sales document item category
WERKS - Plant
The elements mentioned above are only an extract of the possible elements. Overall, the line item E1EDP01 has 52 different elements, such as net sales price (VPREI), price unit (PEINH) etc. Which element is found in 02 is dependent on the ABAP output module in SAP, the predefined customizing, and the type of invoice. When in doubt, the INVOIC02 IDoc documentation helps to determine the meaning of the elements.
The element E1EDP01 is optional and can be found up to 999999 times in an INVOIC02 IDoc.
E1EDP02 - Document Item Reference Data
This element specifies references to other items and documents, which are relevant for given position record.
In the example above, the following reference data is provided:
· Customer purchase order (001)
· Vendor order (002)
As indicated by these entries, the document number, the document date (if there is one) and the reference to the corresponding line item of the document are being provided. This is mostly relevant for collective bills, as the positions do not necessarily refer to the same purchase order or delivery document.
The element E1EDP02 is optional and can be found up to 25 times in the INVOIC02 IDoc.
E1EDP03 - Document Item Date Segment
Date references, which apply to the position record, are provided in element E1EDP03. The Qualifier IDDAT allows to identi what type of date is being used.
In this example the following date values are provided:
· Sales order date (029)
· Delivery date of the supplier (001)
The element E1EDP03 is optional and can be found up to 25 times in an INVOIC02 IDoc.
E1EDP19 - Document Item Object Identification
The element E1EDP19 contains information about identification data of the invoiced product or service, e.g. article number, GTINs or similar. Again, the element QUALF helps to identify the type of identification number being used.
The following values are provided in the example above.
· Material number used by customer (001)
· Material number used by vendor (002)
The element E1EDP03 is optional and can be found up to 10 times in an INVOIC02 IDoc.
E1EDP26 - Document Item Amount Segment
The element E1EDP26 contains information about the price on item level. Depending on the SAP ERP customization and the activated calculation schema, different amounts are provided. This means that not only the gross calculation (the amount without surcharges or deductions) and the net calculation (the amount with surcharges and deductions) are provided, but also every surcharge and deduction as well as any subtotals.
The element QUALF helps to identify the type of amount.
The following amounts are provided in the example above:
· Amount qualifying for cash discount (004)
· Net value (003)
The element E1EDP26 is optional and can be found up to 20 times in an INVOIC02 IDoc.
E1EDPA1 - Document Item Partner Information
This element is used to provide partner information on item level. This partner information is in addition to the one found at header level (E1EDKA1). For example, in the case of a collective invoice, one can enter a different consignee on item level.
The composition of this element is similar to the one of element E1EDKA1 and the qualifiers used in element PARVW are identical.
The element E1EDPA1 is optional and can be found up to 20 times in an INVOIC02 IDoc.
E1EDP05 - Document Item Conditions
The element E1EDP05 specifies the individual condition data records, which are relevant to determine the price of each position. The composition of this element is similar to element E1EDK05, which helps to indicate the conditions at header level.
The element E1EDPA1 is optional and can be found up to 99 times in an INVOIC02 IDoc.
E1EDP04 - Document Item Taxes
This element is used for the specification of the taxes, which are relevant to the position. Its composition is similar to the one of element E1EDK04, which specifies the taxes at document header level.
The element E1EDP04 is optional and can be found up to 25 times in an INVOIC02 IDoc.
E1EDP28 - Document Item - General Foreign Trade Data
The data relevant for foreign trading is specified in element E1EDP28 at item level.
The element E1EDP28 is optional and can be found up to 9 times in an INVOIC02 IDoc.
E1EDP08 - Package Data Individual
If the invoice contains a reference to the product packaging, the packaging information is shown in element E1EDP08. Usually this element is missing in invoices, as the packaging is not relevant for invoices in most cases.
The element E1EDP08 is optional and can be found up to 999999 times in an INVOIC02 IDoc.
E1EDP30 - Document Item Account Assignment Intercompany Billing
This element displays account-relevant information such as cost centers, action numbers, delivery schedule numbers, etc.
The element E1EDP30 is optional and can be found up to 99 times in an INVOIC02 IDoc.
E1EDPT1 - Document Item Text Identification
Similar to the text specified at header level with elements E1EDKT1 and E1EDKT2, E1EDPT1 and E1EDPT2 can be used to display text at item level.
The element E1EDPT1 is optional and can be found up to 99 times in an INVOIC02 IDoc.
E1EDPT2 - Document Item Texts
This element provides the actual text information. Text lines are limited to 70 characters - longer texts can be split into different E1EDPT2 elements.
The element E1EDPT2 is optional and can be found up to 999 times in an INVOIC02 IDoc.
E1EDS01 - Summary segment general
This element provides information about the total amount of an invoice, such as whole net amount, whole gross amount, tax amount etc. The qualifier SUMID identifies the type of amount.
In the example above the following amount types are provided:
· Sales tax total (005)
· Billed value (011)
The element E1EDS01 is optional and can be found up to 30 times in an INVOIC02 IDoc.