How to Post Purchase Invoice via Code

Hi,

We want to post Purchase Invoices from code after it has been saved, we have done a similar customization for the Suppliers and it works perfectly. 

However, for the Purchase Invoices, it does not execute. 

Here is the code snippet we use. It gets invoked, but returns the GOK as 1 and does not update the invoice at all. 

Local Char VALBOUT(250)
Local Char PARBOUT(250)(0..)
PARBOUT(0) = [PIH0]NUM
PARBOUT(1) = num$(GBIDI1)
Call TRAITE_CHAR(VALBOUT,PARBOUT,"","TRTACHFAC1","",1,"XYTRTACHFAC1") From GTRAITE

I've tried different values with the parameters, but to no avail. 

When Posting manually it works and I am calling the exact same function. 

Any ideas or solutions would be greatly appreciated.