You create new field and append it into structure KOMKCV/KOMKCP for account determination.
This works fine during single invoice creation, but wrong G/L account may be determined during collective billing creation.
1 Create new field ZZKUNNR and append it in structure KOMKCV
2, Complete corresponding accounting determination customizing.
The G/L account assignment is maintained as following:
3, Execute collective billing creation via VF04.
4, G/L account 800001 is correctly determined for the 1st invoice document 90036133 with payer 1000, which is created with reference to 1st delivery 80014993.
But G/L account could not get determined correctly starting from for the 2nd invoice 90036134 with payer 1050.
G/L account 800001 for payer 1000 is wrongly determined
The issue is caused by wrong implementation of customer defined field ZZKUNNR in communication structure for account determination.
According to IMG activity documentation of 'new fields for account determination', new field should be added in structure KOMKCV using INCLUDE KOMKCZ.
This makes ZZKUNNR to be one of the fields in structure KOMKCV_KEY_UC.
When value of KOMKCV-ZZKUNNR is determined from user-exit userexit_account_prep_komkcv, system will read komkcv table with KEY komk-key_uc.
There is no problem when the first invoice is processed
The sy-subrc becomes 4 and new entry ok KOMKCV with ZZKUNNR = 1000 is appended.
But since ZZKUNNR is added into structure KOMKCV using INCLUDE KOMKCZ, when the 2nd invoice is processed and system reads komkcv with KEY komk-key_uc,
the read statement is successful this time because the field ZZKUNNR is not included in komk-key_uc.
Then sy-subrc becomes 0, and KOMKCV entry with ZZKUNNR = 1050 is not appended.
As a result, account determination of 2nd invoice will still use previous KOMKCV data, and wrong G/L account is determined.
Refer to IMG activity documentation of 'new fields for account determination', and add new field in structure KOMKCV using INCLUDE KOMKCZ.
Please read following wiki page for more information about new field in account determination.