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:
- How to work without a schema file.
- Use of conditions in the XPath
- Use of second level detail areas.
- Use of combo boxes
The PDF output of the invoice will be:
The report's invoiceIDOC.xre layout is:
The structure of the template is:
- There is a Page header that contains the IDOC number.
- There is a Invoice header that contains the buyer information (bill to and delivered to)
- after the invoice header there may be (optional) some comments to the invoice: Note the Detail 2 area has been associated to the /INVOIC01/IDOC/E1EDKT1/E1EDKT2/TDLINE node. There is one such node in the XML document for each comment line, so the area will be repeated for each comment line. If no comment lines exist, the area will not be created at all. The detail 2 area also has a detail 2 columns header area, this area will be created also only if at least one comment line exists. Furthermore the super area property of the Detail 2 area has been set to the header area.
- after the comments there is a table header for the items in the invoice
- The detail area will be repeated for each item in the invoice. Note the Detail area has been associated to the node /INVOIC01/IDOC/E1EDP01. This element exist for each item in the invoice. Furthermore the super area property of the Detail area has been set to the Header area.
- for each item, there may be (optional) one or several comment lines. Note the Detail 1 area has been associated to the node /INVOIC01/IDOC/E1EDP01/E1EDPT1/E1EDPT2 which contains the item level comments. Furthermore the super area property of the Detail 1 has been set to the Detail area.
- The invoice footer contains some totals information. In the same way as the invoice header, the footer does not have to be associated to any XML node in the XML document since both areas exits only (and always) once in each invoice. This therefore assumes the input XML document (IDOC) can contain only one invoice.
- The page footer contains the legal information of the company issuing the invoice.
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
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:
- An area (Detail 1) has been inserted below the Detail area
- The XML node property of Detail1 is pointing to the /INVOIC01/IDOC/E1EDP01/E1EDPT1/E1EDPT2 which contains the comments of the item.
- The XML node type is set to relative, since the super
area is pointing to /INVOIC01/IDOC/E1EDP01, the XML node
property will refer to the comments of the current line only.
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:
NAME1 node in the /INVOIC01/IDOC/E1EDKA1 node
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.