“Can I do that using x++?”
The answer is - yes, you can ! HOWEVER, this isn’t a soluhtion which can be described in two sentences… could take up to a whole day to develop this.
To post the invoice you will need the information and you already have it all in CustPackingSlipJour table and CustPackingSlipTrans. Those tables contain the original reference to the Sales Orders which they come from, but if for some reason you have already deleted them, you can recreate and post those sales order(-s) in X++.
Take a look this example:
Read data from your CustPackingSlipJour table and CustPackingSlipTrans tables and post the result.