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:
- Added
BUS_ACT = 'RFBU' - explicitly specifies business transaction type
- Added
INV_DOC_CAT - links to invoice category configuration
- Added
OBJ_TYPE = 'BKPFF' - prevents transaction type misinterpretation
- Include
CURRENCYAMOUNT table - 1909 requires explicit currency amounts separate from line items
- Added
BAPI_TRANSACTION_COMMIT with wait flag
Validation Steps:
- Test document type: Transaction FB01 → manual post with type KR → should work
- Check category link: Transaction OBKL → verify KR appears in category assignment
- Test BAPI in debug: Set breakpoint in function module, check internal transaction type derivation
- 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.