Below is from Help file
Determination of Contract Account in ERP System
In the ERP system, the determination of the contract account from a generic contract account key (from any external system) takes place in the BAdI FKKINV_BAPIBILL. This program model also applies for CRM invoicing as source system. A customer implementation of the method CONTRACT_ACCOUNT_DETERMINE for BAdI FKKINV_BAPIBILL is required.
Procedure
If the master data was actually replicated, add the following program lines:
METHOD IF_EX_FKKINV_BAPIBILL~CONTRACT_ACCOUNT_DETERMINE.
DATA: wa_fkkvkp TYPE fkkvkp.
CLEAR wa_fkkvkp.
SELECT * FROM fkkvkp
INTO wa_fkkvkp
WHERE guid EQ x_cont_acct_id.
EXIT.
ENDSELECT.
IF NOT wa_fkkvkp IS INITIAL.
MOVE: wa_fkkvkp-vkont TO xy_cont_acct,
wa_fkkvkp-gpart TO xy_buspartner.
ENDIF.
- ENDMETHOD.
You have to differentiate between the source systems since there is no master data replication between a non-SAP system and the ERP system. You may have to evaluate a customer table that contains the information.