Sales order number -> to purchase/work order?

Hello Comunity!
(Searched hard, but didn’t find)
I have the following situation: We have a furneture sales, mostly by request from several producers/vendors.
When creating sales order I need to create a specific ID for tracking this order through all supplying chain.
We collect sales orders and when it’s enogh quantity to send it to the producer.
So, I need to put all sold products (for specific producer) from all sales orders to one cumulative PO, AND need to put this ID from the sales order for EVERY ordered productsin the purchace order.
Produce put this ID’s (phisically) on the furneture and furneture parts, so, we can identify it.

So, the question is - how to put this ID to each ordered items automatically?
Thank you in advance for any ideas!