Error while reversing document in SAP using BAPI

5.7k views Asked by At

Using BAPI_ACC_DOCUMENT_REV_POST to reverse entries posed via BAPI_ACC_DOCUMENT_POST, however we are getting following errors

E RW 609 Error in document: BKPFF $ SYS600 BKPFF

E RW 632 Document BKPFF 900026 SYS600 cannot be reversed BKPFF

E RW 630 Reversal in component Financial Accounting not possible Financial Accounting

E F5A 009 Reversal not possible, accounting document for the ref. does not exist BKPFF

code for reference

Dim companyAPI As IRfcFunction = _ecc.Repository.CreateFunction("BAPI_ACC_DOCUMENT_REV_POST")
    Dim rev As IRfcStructure = companyAPI.GetStructure("REVERSAL")
    rev.SetValue("OBJ_TYPE", "BKPFF")
    rev.SetValue("OBJ_SYS", "$")
    rev.SetValue("OBJ_KEY", "900026N0342016")
    rev.SetValue("OBJ_KEY_R", "900026N0342016")
    rev.SetValue("COMP_CODE", "D756")
    rev.SetValue("REASON_REV", "01")
    Dim transfunction = _ecc.Repository.CreateFunction("BAPI_TRANSACTION_COMMIT")
    transfunction.SetValue("WAIT", "X")
    companyAPI.Invoke(_ecc) 
    transfunction.Invoke(_ecc)
    Dim dt As DataTable = GetDataTableFromRFCTable(companyAPI.GetTable("RETURN"))
1

There are 1 answers

0
mjturner On

At first glance, the final error message (E F5A 9 ...accounting document for the ref. does not exist BKPFF) points to a possible solution.

I see you're passing the document number (900026), company code (N034) and financial period (2016) as the key but I have a feeling you need to zero-pad the document number to ten digits. Send OBJ_KEY and OBJ_KEY_R as '0000900026N0342016` and see if that helps. The document number is stored internally as ten digits and I think the BAPI is expecting it in that format.