In many situations, we need to navigate from Quote to Invoice in our custom code. Even if you are not a technical consultant, it might be worth understanding how SAP links and integrates them. This article describes how you can traverse through this chain from a technical standpoint. This specific document is meant for SAP Sales and Distribution consultants as well as technical folks.
The whole topic can be summarized in a simple picture below which shows various SAP SD documents linked an order. It shows SAP order linked with delivery as well as Invoice document. The first invoice has been cancelled for some corrections and the invoice has been generated again.
The technical relationship tables and key values
The relationship is managed in database table VBFA. The following are the critical fields in this table so that you can navigate forth or back from a sales document number. It must be noted that SAP is inherently designed for linking multiple subsequent document from a source document. Therefore, the relationship is handled at a line item level.
Let us look at the following example. Let us say that an order 1000 has two line items. There are two subsequent delivery documents 2000 and 2001. Delivery document 2000 can have an invoice 3000 and delivery 2001 could be invoiced with 3001.
Following are the key fields which determine the relationship between two documents.
- VBELV – Preceding sales and distribution document
- POSNV – Preceding item of an SD document
- POSNN – Subsequent item of an SD document
- VBTYP_N – Document category of subsequent document
- VBTYP_V – Document category of preceding SD document
Following are the document categories for some usual SD documents.
Example Scenario 1. From Sales order to Delivery Document
Let us say that you want to arrive at the sales order number from a delivery document. Following are the key things you need to know
- Sales Order Number
- Document category of subsequent document. In this case the delivery document is the subsequent document. The document category for delivery is ‘J’.
- Document category of preceding document. Document category of preceding SD document. In this case the sales order number is the preceding SD document. The document category for the same is ‘C’.
- Item Number – If you have a scenario like an order can have single delivery document, then it is simple. Otherwise, you need to supply the item number in delivery document.
Example #2. Traversing from Delivery document to Invoice document
Now in this case, invoice is the subsequent document and delivery is the preceding one. Rest all the factors remain the same.
- Delivery Document Number
- The document category for Invoice is ‘M’ (subsequent document).
- The document category of delivery is ‘J’ (preceding document).
- Item Number – Again the same case as explained above in example scenario #1.
# Awesome tip on how to test a BAPI which does not commit to database without writing a wrapper or any custom code.
A closely related to the topic in this article is about copy control. To understand this consider this simple statement. A lot of information gets copied from a preceding sales document to a subsequent one while other gets generated afresh. This information to be copied is set up using copy control. As you can see below, this information is defined in transaction VOFM under transfer data section.
Now you are all set. You have got of good background in understanding how SAP handles relationship between documents specially for sales and distribution area.