• January 29, 2026
  • Kishore Thutaram
  • 0

Duplicate Invoice check using BTE

Business Scenario:

Duplicate invoices during AP invoice entry based on the vendor and invoice number. If duplicate invoice found, generate an error message. 

SAP business transaction events would be used for this enhancement.

Steps :

1. Open FIBF transaction

2. settings -> process modules -> of a customer

3. Process (00001110) – copy standard sample FM into Z

Logic inside the custom FM

    
        IF i_lifnr IS NOT INITIAL AND i_xblnr IS NOT INITIAL.
-- Fecth reference accounting info from z_i_rtr_vendor_inv_index CDS
SELECT CompCode, "Compnay Code
Vendor, "Vendor number
Currency, "Currency
DocumentDate, "Document Date
ReferenceDocument, "Reference Document -XBLNR
Amount, "Amount
AccountingDocument, "Accounting Document - BELNR
FiscalYear, "Fiscal year
AccountingDocumentItem, "Accounting Document Line Item
AccountingDocumentRef, "Accounting document
ReverseDocument "Reverse Dcouemnt
FROM  INTO TABLE @DATA(lt_accounting)
WHERE vendor = @i_lifnr
AND ReferenceDocument = @i_xblnr
AND AccountingDocument NE @i_belnr
AND reversedocument = ' '.
IF sy-subrc EQ 0.
LOOP AT lt_accounting ASSIGNING FIELD-SYMBOL().
-- If the new accounting document matches with old one, consider it as duplicate
IF -AccountingDocument = -AccountingDocumentref.
e_nostd = abap_true.
MESSAGE e002(zrtr) WITH -AccountingDocument
-CompCode
-ReferenceDocument.

      EXIT.                                         "#EC CI_NOORDER
    ENDIF.
  ENDLOOP.
ENDIF.

ENDIF.
    
    

Kishore Thutaram

"SAP solution architect with a strong problem-solving mindset, sharing practical SAP S/4HANA and ABAP insights from real-world projects."

https://fiowelt.com