How to determine the latest bank statement in FEBKO and FEBEP?
Here we have the requirement to select the latest bank statement from FEBKO (statement header) and FEBEP (statement line item), the 'latest' means if there are multiple bank statements imported for one day (later one overwrites old ones), we need to reply on the latest one to read the latest information from bank. And further, the 'latest' one is not always the last one statement imported physically, because there is the situation that there are more than one statements sent from bank, but the importing order (by the company) is messed up.
Our current approach:
for example, if we want to get the latest bank statement overall, we get the entries in FEBKO with highest value in AZDAT (Statement Date), and if there are multiple entries in results, we select the entry with highest value in KUKEY (Short Key).
And it is the same logic used in SAP report RFEBKAMON01 for bank statement monitor.
However this logic cannot solve the case with messed up importing order as mentioned before.
Another candidate option is to leverage field AZNUM (Statement Number), which is entered according to the sequence of statement from business perspective. It looks like a perfect solution.
But, we checked some customer data sample, that there are some cases that value of AZNUM is blank, according to the logic above, those entries will not be selected out. Now the question is whether the entries with blank AZNUM are valid case or exceptional ones that we can ignore.
Can anybody offer some help to us here?
Thanks a lot.