Link between shipped and invoiced sales line

Situation:
Create a sales order, ship a sales line it from the sales order.
Now create a sales invoice, Functions–>Get Shipment Lines, insert the shipped sales line.
Post the invoice.

Now I want to find out, what shipment line this newly created invoice line refers to.

Is there any table that stores the link?

Any other way to find out the “Document Date” and “Order Date” from the original order after the order is completely invoiced (an thus deleted from table 36/37)?

Thanks for any suggestions.

Hmm why dont you read the code that fills it?

About the doc/order date. If they do not exist you can just add them to the invoice header.

ad 1.) What code do you mean? I do not see any reference in the posted invoice line that goes back to the shipment lines. But there must be some (on the original sales order for instance the field “Qty. invoiced” is modified for items, resources etc.).

ad 2.) An invoice can contain shipment lines from different shipments; so it is not possible to fill any header fields from the shipment header(s).

Hi

Have a look at the item ledger entry from the invoice of a particular item, if you drill into the cost field you will see the shipment and invoice on separate lines.

Hi Steven,

thanks for your answer. For items that will work (also I found I could use the value entry relation table). But what about invoices with only a resource or only a G/L entry or only an item charge?

Thanks.

The code that does this

then what did you mean by?

Since fully posted orders arent the same as shipped headers(1 to many relation).

Yes, you are right. That is why I try to compare the lines to the original shipment lines. One postedm invoice line will always relate to exactly on posted shipment line. From there I would find the shipment header and the Order/Document Date.

For items, I can use the value entry relation table to find the value entry, the item ledger entry, the shipment line etc.
For resources, G/L Acclunts and Item Charges there is no such table.
I have analyzed the code, but it is no use for me - the system uses the information stored on the sales line to get all the info, but after that it will be deleted.
It is a shame that the information present on the sales lines (posted Shipment No., Shipment line No.) are not being transferred to the posted invoice lines…

That is not the case. Its a many to many relation and as such it cannot be stored in one line.

Same as above. And that is one of the reasons why there is no link between the posted invoice and the posted shipment.

/nod. But that is because you dont ship those.

Maybe since the original order no is stored on both tables you can make a form with the two types of lines(the non-zero ones) and show those just like you see the posted docs from order when clicking the sales history in version 4.0+. Would atleast give the customer the overview on what happened to the order and when.

One method i use is to add 2 new fields to the Sales Order Line table:
Order No. and Order Line No.

Then in the function from the posted sales shipment lines;

InsertInvLineFromShptLine(VAR SalesLine : Record “Sales Line”;VAR TempFromDocDim : TEMPORARY Record “Document Dimension”)

Add:
(after the next line)
SalesLine.“Qty. Invoiced (Base)” := 0;
///
SalesLine.“Order No.” := “Order No.”;
SalesLine.“Order Line No.” := “Order Line No.”;

The new fields are also added to the posted sales invoice lines table so they are then updated automatically.

Now you have the information needed to link it all together.

I have also created a new “Navigate” based only on the “Order No.” that does that job. It is very useful to the clients and is quite simple to develop.