Beside the creation of workflow events from standard SAP transactions, SAP has introduced the business transaction event, the so called BTE. For instance, during the posting of accounting documents bte 00001030 is triggered. But how will you find out which bte is triggered and when ?
In transaction FIBF you can customize these bte's and link function modules (for instance a copy of SAMPLE_INTERFACE_00001030) to the bte. During the SAP transaction, the program has to check which functions need to be called for that bte. This is done by function module BF_FUNCTIONS_FIND.
The next step is to add a breakpoint in the source code of this function module.
Then you go start your SAP transaction (let's say FB01) or bapi (for instance BAPI_ACC_INVOICE_RECEIPT_POST). The program stops in function module BF_FUNCTIONS_FIND. The value of the bte can be found in variable I_EVENT.
With this knowledge you can go start customize the BTE mechanisme for the found bte by using transaction FIBF.