Financial accounting BAPI posting fails with document type mismatch error

Automated invoice uploads using BAPI_ACC_DOCUMENT_POST are failing with document type mismatch errors. We’re posting vendor invoices (document type KR), but SAP rejects them with “Document type KR not allowed for transaction type RF”.

The BAPI call structure looks correct to us:

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
    documentheader = ls_header  "BLART = 'KR'
  TABLES
    accountgl = lt_gl
    accountpayable = lt_vendor
    return = lt_return.

Manual invoice posting through FB60 works fine with the same vendor and GL accounts. Only the BAPI automation is blocked. Invoice upload processing is stopped completely. Has anyone resolved document type mapping issues with BAPI_ACC_DOCUMENT_POST on 1909?

I’ve debugged numerous BAPI_ACC_DOCUMENT_POST issues on SAP 1909 and the “document type not allowed for transaction type” error typically stems from three configuration misalignments:

1. BAPI Document Type Mapping: The BAPI uses internal transaction type derivation logic that differs from manual FB60 posting. Transaction OBA7 (document type configuration) has hidden dependencies that affect BAPI behavior.

For document type KR (vendor invoice):

  • Go to OBA7, select company code, click ‘Document Types’
  • Select document type KR
  • Check the ‘Account Types Allowed’ section - ensure ‘K’ (vendor) and ‘S’ (G/L account) are both checked
  • CRITICAL: Click ‘Document Type Categories’ button (often missed)
  • Verify KR is assigned to category ‘AP’ (Accounts Payable)
  • If category is missing or set to ‘FI’ (general), BAPI interprets it as wrong transaction type

2. Invoice Category Configuration: SAP 1909 introduced mandatory invoice category validation for compliance. Transaction OBKL (invoice category maintenance):

  • Create or verify invoice category exists (e.g., ‘INV_VENDOR’)
  • Assign document type KR to this category
  • Set ‘BAPI Posting Allowed’ flag (this is the key setting that’s often unchecked)
  • Define category attributes:
    • Transaction Type: ‘RFBU’ (vendor invoice posting)
    • Document Category: ‘AP’
    • Posting Interface: ‘BAPI’ (not just ‘MANUAL’)

Then link the category to your BAPI call by adding invoice category to DOCUMENTHEADER:

ls_header-blart = 'KR'.           "Document type
ls_header-inv_doc_cat = 'INV_VENDOR'.  "Invoice category
ls_header-obj_type = 'BKPFF'.     "FI document object
ls_header-obj_key = space.        "Will be filled after post
ls_header-obj_sys = sy-sysid.

3. Automation Script Update: Your BAPI call needs additional parameters for 1909 compatibility. Complete working example:

DATA: ls_header TYPE bapiache09,
      lt_gl TYPE TABLE OF bapiacgl09,
      lt_vendor TYPE TABLE OF bapiacap09,
      lt_currency TYPE TABLE OF bapiaccr09,
      lt_return TYPE TABLE OF bapiret2.

" Header - complete all required fields
ls_header-bus_act = 'RFBU'.      "Business transaction
ls_header-username = sy-uname.
ls_header-header_txt = 'Automated Invoice'.
ls_header-comp_code = '1000'.
ls_header-doc_date = sy-datum.
ls_header-pstng_date = sy-datum.
ls_header-doc_type = 'KR'.       "Vendor invoice
ls_header-inv_doc_cat = 'INV_VENDOR'.  "Link to category
ls_header-obj_type = 'BKPFF'.
ls_header-ref_doc_no = 'EXT-INV-12345'.  "External reference

" Vendor line item
APPEND VALUE #(
  itemno_acc = '1'
  vendor_no = '100001'
  comp_code = '1000'
  item_text = 'Vendor Invoice'
  pmnttrms = '0001'
  bline_date = sy-datum
) TO lt_vendor.

" G/L line item
APPEND VALUE #(
  itemno_acc = '2'
  gl_account = '400000'
  comp_code = '1000'
  item_text = 'Expense Account'
  costcenter = 'CC-1000'
) TO lt_gl.

" Currency amounts
APPEND VALUE #(
  itemno_acc = '1'
  currency = 'USD'
  amt_doccur = '1000.00'
) TO lt_currency.

APPEND VALUE #(
  itemno_acc = '2'
  currency = 'USD'
  amt_doccur = '-1000.00'
) TO lt_currency.

" BAPI call with commit
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
    documentheader = ls_header
  TABLES
    accountgl = lt_gl
    accountpayable = lt_vendor
    currencyamount = lt_currency
    return = lt_return.

IF NOT line_exists( lt_return[ type = 'E' ] ).
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'.
ENDIF.

Key Changes from Pre-1909 Implementations:

  1. Added BUS_ACT = 'RFBU' - explicitly specifies business transaction type
  2. Added INV_DOC_CAT - links to invoice category configuration
  3. Added OBJ_TYPE = 'BKPFF' - prevents transaction type misinterpretation
  4. Include CURRENCYAMOUNT table - 1909 requires explicit currency amounts separate from line items
  5. Added BAPI_TRANSACTION_COMMIT with wait flag

Validation Steps:

  1. Test document type: Transaction FB01 → manual post with type KR → should work
  2. Check category link: Transaction OBKL → verify KR appears in category assignment
  3. Test BAPI in debug: Set breakpoint in function module, check internal transaction type derivation
  4. Review application log: Transaction SLG1, object ‘FI_DOC_POST’, look for validation failure details

Common Pitfall: The error message “transaction type RF” is misleading. RF usually indicates reference document posting, which suggests the BAPI is interpreting your call as a down payment or advance payment transaction instead of a regular vendor invoice. This happens when invoice category is misconfigured or missing.

After implementing all three configuration areas (document type categories, invoice category BAPI flag, and updated BAPI call with proper parameters), your automation should process vendor invoices successfully. The critical change is adding invoice category to the BAPI header - this was optional in older versions but mandatory in 1909 for automated posting.


This draft is based on general SAP S/4HANA knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.

The transaction type RF suggests you’re triggering a different posting transaction than intended. Check what’s in your DOCUMENTHEADER-OBJ_TYPE field. If it’s not set or incorrectly set, the BAPI might be interpreting your call as a different document category. For vendor invoices, OBJ_TYPE should be ‘BKPFF’ (FI document) not ‘RF’ (reference document).

Also verify your document type configuration in transaction OBA7. Even if document type KR exists and works in FB60, it might have restrictions on automated posting or BAPI usage. Check the ‘Document Type’ entry for KR and look at the ‘Posting Control’ tab - there’s a field for ‘Batch Input Only’ that would block BAPI calls if checked.

Tested this on SAP S/4HANA 1909 — verifying the ‘K’ vendor account type checkbox in OBA7 for document type KR resolved our BAPI_ACC_DOCUMENT_POST transaction type mismatch immediately.

I checked OBA7 and the ‘Batch Input Only’ flag is not set for document type KR. The OBJ_TYPE field in our BAPI call is not explicitly set - we’re only populating BLART with ‘KR’. Should OBJ_TYPE be mandatory? Our BAPI documentation doesn’t mention it as required for vendor invoices. What value should I use?

OBJ_TYPE is implicitly derived if not set, but the derivation logic can fail in certain scenarios. For vendor invoices via BAPI_ACC_DOCUMENT_POST, explicitly set OBJ_TYPE = ‘BKPFF’ and OBJ_KEY to the document number you’re expecting. Also make sure you’re calling BAPI_TRANSACTION_COMMIT after the post. Without commit, the document stays in an inconsistent state and can trigger weird validation errors like transaction type mismatches.

Check your invoice category configuration. In SAP 1909, there’s a new validation layer that maps document types to invoice categories for compliance tracking. If your automation script is posting invoices without proper invoice category assignment, it triggers the transaction type mismatch error. Transaction OBKL (invoice category definition) - make sure KR document type is linked to appropriate invoice categories and those categories allow BAPI posting.