I need to update the payment block indicator in the MIRO transaction through custom code instead of doing it manually. I’m working on an automation project where invoices need to have their payment status modified based on certain business conditions.
I’ve been looking into different approaches like using standard BAPIs, function modules, or direct table updates but I’m not sure which method would be the most reliable and safe.
Has anyone successfully implemented something similar? What would be the recommended approach to programmatically control the payment block field? I want to make sure I follow SAP best practices and avoid any data integrity issues.
Any code examples or guidance on the right direction would be really helpful. Thanks in advance for your suggestions!
fb02’s function modules handle payment block updates really well. i’ve wrapped fm_document_change in custom code before - worked great for our invoice automation. just handle document locking properly or you’ll run into issues with multiple users hitting it at once.
You can update the RBKP and RSEG tables directly, but I advise against it. It might seem simpler to change the SPBLK field, but you’ll bypass SAP’s validations and change documents, which is problematic for audit trails. I learned this the hard way when auditors questioned missing change history on a project I worked on. There’s also the MRM_INVOICE_UPDATE function module that is often overlooked, but it’s reliable for bulk updates. However, it’s best to stick with the BAPI method as it performs all the necessary checks and ensures your document flow remains intact. Just ensure that the F_BKPF_BLA authorization object is configured correctly, or you might encounter dumps during execution.
bapi_incominginvoice_change works great for this! just ensure you’re using the right invoice number to update the payment block in header data. oh, and remember to use bapi_transaction_commit after; otherwise, changes won’t be saved.
I’ve used BAPI_INCOMINGINVOICE_CHANGE on several projects - it’s definitely the safest route, but there’s more to consider. You’ll need the document number in INVOICEDOCUMENT, and the payment block indicator goes in the HEADERDATA structure. Look for PMNTTRMS_BLOCK in the header data - that’s your key field. Don’t forget to fill the matching flag in HEADERDATAX so it knows which fields you’re changing. Test this thoroughly in dev first because messing with invoices can impact payment runs and upset vendors. Build in solid error handling too - the BAPI provides good error messages when things go sideways.