Identifying a Sales Order from a Production Order using reservation entries.

Hi All,

I have a manufacturing customer who needs to be able to print a label for their shop floor. They need to print the label from a production order but print the Sales Order Number on the label as they run a “make-to-order” production setup. The challenge is that they have a multilevel production order setup. For example, via MRP, a Sales Order for a table has created a production order for a table, which has created a production order for a table-leg, which again has created a production order for a leg-foot.

The challenge is to be able to identify the original sales order from a production order a bit down the hierarchy. So I essentially need a codeunit, when you tell it the number of a production order it is able to reply with the Sales Order Number.

If you look at the reservation entries below it is possible to perform this exersice “manually” but I need some code that can do this. For example, the bottom line has Production Order Number 101053 and I can back track that to be connected to the sales order 1016.