I have read a couple of posts that talk about this invoice reference field and almost all the sources point out that the field is filled at the time of document creation.
Here, I have a document that was created using an xml file.
No 'V' anywhere.
And once the document is created, the Invoice reference field of lineitem1 is automatically populated with 'V'.
The field is blank for the 2nd line item, though...
Can someone tell me any reason as to how this automatically becomes 'V'?
Is it something to do with credit memo? Or the date, maybe?
Or where I can find the logic?
Thanks, in advance...
I guess you'll not get a satisfactory answer for this question here. There are a few reasons for that.
The screenshot of the source XML-file for this credit memo is of no use. The only hint it provides is that the credit memo was not posted manually, but rather through an interface. It means that there is some custom program in background that is reading the XML-file and posting the accounting document. But it is not clear how the program is posting accounting documents - through BAPI BAPI_ACC_DOCUMENT_POST, BDC session or some other way. Let's suppose it is a BAPI. The program implements some mapping logic between the values in the source files and input parameters for the BAPI. This logic is specific to your client's SAP system and without access to it, no one would be able to deduce how it works.
Next, apart from the custom program, there might be a myriad of enhancements in your system (e.g. accounting substitution, user exits (e.g. BTE-events), BADI ACC_DOCUMENT etc. Any of these places might have an enhancement that checks if there is a reference to sales invoice and if it is not provided the field BSEG-REBZG will be filled with a fixed value "V".
So the best way to check is to analyze the source code for the program that deals with this XML-file with a developer and see how this field is treated.
P.S. My memory is not 100% correct, but I think I once encountered a case of replication of accounting documents for standalone credit memos posted in one SAP system (in SD module) to another SAP system. The replication was based on IDOCs and if I'm not mistaken the value "V" was filled automatically by standard SAP logic during replication.