2020 Oct 13 9:27 PM
Hello,
I have a requirement to create an Incoming Invoice, with an additional check to avoid duplicate invoice creation. For this I am calling MRM_DUPLICATE_INVOICE_CHECK FM but the program gives out an Error (see the image below) and exits. My goal is to trap the error that is displayed and then display a summary for the user. Is there a way to do that?
I have tried MRM_FI_DOCUMENT_CHECK and FI_DUPLICATE_INVOICE_CHECK with the same results.
CALL FUNCTION 'MRM_DUPLICATE_INVOICE_CHECK'
EXPORTING
i_bukrs = 'IM21'
i_lifnr = '00139'
i_waers = 'USD'
i_xblnr = 'VENDORINV001'
i_bldat = '20201006'
i_rmwwr = '931.2'
i_xrech = 'X'
* I_BELNR =
* I_BLART =
* I_PREPAY_AWKEY =
EXCEPTIONS
INVOICE_ALREADY_EXISTS = 1
OTHERS = 2
.
BREAK-POINT.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
WRITE : / 'Invoice already created for given Reference #'.
ENDIF.

Thanks.
Hello,
I have a requirement to create an Incoming Invoice, with an additional check to avoid duplicate invoice creation. For this I am calling MRM_DUPLICATE_INVOICE_CHECK FM but the program gives out an Error (see the image below) and exits. My goal is to trap the error that is displayed and then display a summary for the user. Is there a way to do that?
I have tried MRM_FI_DOCUMENT_CHECK and FI_DUPLICATE_INVOICE_CHECK with the same results.
CALL FUNCTION 'MRM_DUPLICATE_INVOICE_CHECK'
EXPORTING
i_bukrs = 'IM21'
i_lifnr = '00139'
i_waers = 'USD'
i_xblnr = 'VENDORINV001'
i_bldat = '20201006'
i_rmwwr = '931.2'
i_xrech = 'X'
* I_BELNR =
* I_BLART =
* I_PREPAY_AWKEY =
EXCEPTIONS
INVOICE_ALREADY_EXISTS = 1
OTHERS = 2
.
BREAK-POINT.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
WRITE : / 'Invoice already created for given Reference #'.
ENDIF.

Thanks.
2020 Oct 13 10:24 PM
Hi Amit
Can you confirm if at the vendor master data you checked double inv checkbox
This can also be handled by the config not sure if you still want to use the Function module?
SPRO->Materials Magement -> Logistics invoice verification -> Incoming invoice -> Set check for Duplicate invoices.
Follow a document here which also explains the checks you need to maintain at vendor master record level
https://blogs.sap.com/2013/01/24/duplicate-invoice-check-part-1/
Also refer to this note
2036775 - Duplicate Invoice Check in Logistics Invoice Verification
it talks about using the FM you are using
Both of them are called in functions MRM_DUPLICATE_INVOICE_CHECK and MRM_FI_DOCUMENT_CHECK respectively and can be set as errors or information messages in transaction OMRM.
It also mentions a BADI
"NOTE: Method HEADERDATA_CHECK from the BAdI MRM_HEADER_CHECK could be used to check additional fields."
Last line says " the check will only work for the documents created after the customizing has been done as per this KBA. If a document has been created before the settings, the duplicate check will not be raised for a new one even though the customizing is set."
So you probably need to follow the note and then try again
Let me know if that helped.
Regards
Vinita
2020 Oct 13 11:16 PM
Thanks Vinita for the lucid details. Actually, the things that you have mentioned are already done and the settings are working as expected in MIRO: Error message comes up when user enters a duplicate Vendor Invoice.
Now we want to automate Incoming Invoice creation: Vendor will send Invoice data in Excel and we on our end will upload data and create the invoice (via BAPI_INCOMINGINVOICE_CREATE).
BAPI_INCOMINGINVOICE_CREATE is working great but it is not giving 'Duplicate Invoicing' error (even after the SPRO changes), so I have to resort to MRM_DUPLICATE_INVOICE_CHECK (or other FM's) and try to trap the 'Duplicate Invoice' error. That is where I got stuck. The source code that I have pasted in my original post, uses hard coded data for checking purposes but I will have multiple Vendor References for which I need to trap the 'Duplicate invoice' error and present it to the user.
I can of course check table RBKP to check if Invoice is already created for the Vendor Reference in Excel, but would prefer if the 'DUPLICATE INVOICE CHECK' FM's can be used.
2020 Oct 15 11:07 AM
Don't raise the error with the MESSAGE statement, but add it to some application log.
In the meantime, correct your code, e.g.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
INTO l_text
WRITE : / l_text.
" Skip and go to Next record
ELSE.
" Call BAPI
ENDIF.Also read OSS note 2511288 - Logistics invoice verification APIs: Check for duplicate invoices ('Up to now, no check has been carried out for duplicate invoices for the interfaces specified....')
2020 Oct 20 8:23 AM
2020 Oct 19 10:25 PM
Thanks Raymond, but we are still on ECC and the note 2511288 won't help us.
And regarding the MESSAGE statement, the program execution does not even reach the 'IF Sy-SybRc <> 0' statement. The Error message screen shown in my original post, comes up before that. I understand that probably is because of the configuration but I want to trap the Error and then move to the next record.
-Amit.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |