I need help with calling my custom function module automatically when users post invoices through MIRO or FB60 transaction codes. I have been trying to trace the system events to find the right trigger point, but I cannot locate any existing function modules in the standard system that would help me identify the correct event details.
I want to hook into the posting process so my custom logic runs every time an invoice gets posted. Has anyone successfully implemented this kind of automatic trigger? What approach would work best for capturing the invoice posting event and executing my custom code at that point?
Enhancement spots are your best bet here. I did something similar a few years ago and the enhancement framework was way more reliable than trying to catch business transaction events. For MIRO, check out enhancement spot MM_INVOICE_POSTING - it’s got several BAdIs that trigger at different points during posting. FB60 has its own enhancement points in the FI posting logic. You need to figure out which BAdI gives you the document data at the right time. I went with INVOICE_UPDATE since it fires after validation but before final commit. Just make sure your custom code doesn’t mess with the standard posting flow - keep it lightweight and handle errors gracefully so you don’t block the transaction.