Advertising:
Classic BAdI ACC DOCUMENT
From SAP Knowledge Base
BAdI use in relation to BAPI_ACC_DOCUMENT_POST and its extension parameter 'extension2'
Create implementation in customer namespsace
The BAdI can be used multiple times and your own implementation can be created. Before you can save this, a filter must be assigned which reference process is relevant. With regard to the BAPI_ACC_DOCUMENT_POST, the reference process 'BKPFF' must be used here. For manual posting it would be 'BKPF', for BAPI or batch input folders it is 'BKPFF'.
Procedure: Set posting key explicitly
For example, if an FB01 posting is created with BAPI_ACC_DOCUMENT_POST and the extension parameter 'extension2' was previously specified, the implementation in customer namespsace is run.
Code must be programmed accordingly in the interface method 'CHANGE' so that the BAPI_ACC_DOCUMENT_POST works with the defined posting key: https://answers.sap.com/answers/3883521/view.html