SalesOrder --> DeliveryOrder --> Invoice Link
I am working on a little project here to Invoice DeliveryOrders generated by a manual SAP SalesOrder.
Yesterday Owen helped me discern between the DeliveryOrder generated from a manual SAP SalesOrder
and a DeliveryOrder generated from an AddOn...so I am good there.
I have 2 questions:
1) After entering the SalesOrder through SAP, I hit the CopyTo Deliveries button. How can I tell which SalesOrder
produced the DeliveryOrder? Is there a link somewhere that I am missing?
2)After using the DeliveryNote and Invoice objects, I generated the Invoice for the DeliveryOrder. Same question
here...How can I tell which DeliveryOrder produced the Invoice? Is there a link somewhere that I am missing?
Since, I am generating the Invoice, perhaps I need to update a Userfield on the Invoice with the DeliveryOrder
number as well as updating a UserField on the DeliveryOrder with the Invoice number.
What is everyones opinion here on how I can handle this?
Thanks for the assistance,
Owen Slater replied
On each of the marketing document row tables, you'll find the fields BaseEntry, BaseType and BaseLine. These fields link the row back to a row on the base document. This is a much more flexible solution than linking at the header level because, for example, it allows you to link multiple deliveries back to a single sales order or to merge multiple sales orders in to a single delivery. The link is always backwards (ie the base sales order link is held in the delivery rows but the target delivery is not held in the sales order rows).
BaseEntry = DocEntry of the base document (eg on the DLN1 table for deliveries, the BaseEntry will show the DocEntry of the sales order).
BaseType = This is an enumeration which holds the document type of the originating document (eg 17 = sales order, 15 = delivery for a full list see the SDK Help Center)
BaseLine = The LineNum of the base row
I create a sales order with DocNum 10000 and DocEntry 10. This document has 2 rows (linenum 0 and 1). I then copy the first row to a delivery using the UI. When I save the delivery , the DLN1 will have one record for my delivery. This record will have BaseType 17 (=sales order), BaseEntry 10 and BaseLine 0. I then copy the second row of my sales order to a new delivery. This will have BaseType 17, BaseEntry 10 and BaseLine 1 in the DLN1 table. I then copy both deliveries to a single sales invoice. Now I have 2 lines in the INV1 table with BaseType 15 (=delivery), BaseLine 0 and the BaseEntry values will show the DocEntry of the deliveries (one on each row).
I can also do the same thing via the DI API by setting the BaseType, BaseEntry and BaseLine properties in the Document_Lines object.
Hope that makes sense