Execute custom function when posting documents in FB60 or MIRO transaction

I need help with automatically calling my custom function module during document posting

I’m working on a requirement where I need to execute my own function module whenever users post invoices through FB60 or MIRO transactions. I’ve been trying to figure out the right approach for this.

So far I attempted to use event tracing to identify the correct trigger points, but I’m not seeing any default function modules being called that I could hook into. This makes it difficult to determine which events I should be listening for.

What would be the best way to achieve this automatic execution? Are there specific user exits or BADIs that work well for these transactions? I’m looking for a reliable method that will consistently trigger my custom logic during the posting process.

Any guidance on the proper implementation approach would be really helpful.

hey, if ur looking for a way to hook into fb60, i found badi INVOICE_UPDATE works well, and for miro, look into MB_MIRO_BADI. they trigger pretty reliably during posting.

Both FB60 and MIRO utilize the same posting engine, allowing you to tap into the commitment control phase effectively. In my experience, the enhancement point FAGL_ITEMS_CH_DATA in the new GL posting logic has proven to be reliable. It triggers right during document creation, granting you full access to the posting data prior to final commitment, making it an ideal moment to modify any postings if necessary. Additionally, consider leveraging the business transaction event framework via FIBF. By registering your function module for event 00001020 on vendor invoices, you ensure cleaner integration tailored to financial document events, which correctly manages posting context. The event framework also offers enhanced error handling, which can gracefully terminate a posting transaction if the custom function fails.

Skip the SAP user exits and BADIs headache - set up external monitoring that watches these transactions instead.

I’ve been down this road before. SAP modifications break during upgrades and you need ABAP skills to keep fixing them. Not worth it.

Better solution: create automated monitoring that catches FB60 or MIRO transactions when they complete, then triggers your custom function automatically.

You’ll avoid touching core SAP code and keep your custom stuff separate. The automation hits your function module through RFC or web services once it spots the posting event.

Way more reliable since it runs independently of whatever SAP changes internally. You can also add proper error handling, logging, and retry logic - stuff that’s a pain with user exits.

Latenode makes this SAP automation dead simple. Build the monitoring and triggers without coding, and it handles SAP connectivity for you.

For FB60 and MIRO document posting triggers, check out the FI_DOCUMENT_CHANGE enhancement spot. It’s got several BADIs that fire during posting. I’d recommend FI_DOC_CHANGE_ITEM since it triggers right before the document hits the database. You could also use the substitution framework via OBBH to set up rules that run your function module based on field values or conditions. This route’s configuration-based, so it survives upgrades better. In my experience, mixing the substitution framework with a custom validation rule gives you the best control over when your function executes. You’ll catch it at the right point in the posting cycle and have access to all the document data you need.