7. The invoice IDOC example explained
The idoc_invoice subdirectory shows how you can create a user friendly PDF file from a SAP XML IDOC. This example has been based on the INVOIC01 format but it can be easily changed to be used with other IDOC types or versions.
In this section we will highlight some common task like:
The report's invoiceIDOC.xre layout is:
The structure of the template is:
how to work without a schema file
In this example we do not have a XSD file that describes the IDOC
invoice, therefore we click on the Create schema from XML button
in the settings tab of the report, select the
Use of second level detail areas
As already described in the structure of the template, this example contains a second level detail area called "detail 1". This area contains the comments associated to the items of the invoice.
The key steps to achieve this are:
Use of conditions in the XPath
The bill to and delivered to information show a very common pattern in XML structures. The XML node /INVOIC01/IDOC/E1EDKA1/NAME1 contains the name of a company, but the meaning of the company is described by another node, namely the /INVOIC01/IDOC/E1EDKA1/PARVW. If the content of that node is RE, it means the data in the parent node refer to the bill to party. That is why the used XPath is:
/INVOIC01/IDOC/E1EDKA1[PARVW='RE']/NAME1
NAME1 node in the /INVOIC01/IDOC/E1EDKA1 node
that
meets the condition PARVW='RE'.
type in the condition part of the Xpath in the bottom field of the XPath selector window. You can add condition in square brackets [ ] at any position of the XPath.
The first field in the invoice header is a good example for a combo
box. The XML node /INVOIC01/IDOC/E1EDK14[QUALF='015']/ORGID
can contain the values F2 or G2 which do not mean anything to a
normal user. The combo box allows you to replace this codes with the
descriptive values "invoice" and "credit note" which are the business
meaning of those code.