The easiest way is to for purchase invoice header to purchase header. The field order no. in the purchase invoice header relates to the no. in the purchase header table.
From the purchase header you can look at the field called "Last posting no." then will give you the purchase invoice no. for the last invoice posted from that purchase header.
But remember there can be several purchase invoices connected to one purchase header. Thats why I recommend you go from purchase invoice to look at purchase header. Because one purchase invoice will only refer to one purchase header. Unless you use combined receipt. Then you need another aporach.