We tried to generate a payment and the error F5787 showed.
After several days, we noticed that the FI Document and the Vendor must have the same Quantity of Tax Codess actived. In the next image we can see that in the Vendor (left) were 4 tax codes and in the document (right) were 6 tax codes. (THIS MUST BE THE SAME)
Just make the changes on the vendor that matches the document (if you cant void the document).
Hope it helps!