Validar que no se repita la referencia externa en facturas de proveedor en SAP S4 Hanna

Se debe implementar la badi MRM_CHECK_INVOICE_CLOUD

con el siguiente código:

DATA(lv_reference_value) = headerdata-supplierinvoiceidbyinvcgparty.

IF action = if_ex_mrm_check_invoice_cloud=>c_Action_Check
OR action = if_ex_mrm_check_invoice_cloud=>c_action_post
OR action = if_ex_mrm_check_invoice_cloud=>c_action_save_as_completed
OR action = if_ex_mrm_check_invoice_cloud=>c_action_park.

SELECT SINGLE SupplierInvoice,
CompanyCode
FROM i_supplierinvoiceapi01
WHERE supplierinvoiceidbyinvcgparty = @lv_reference_value
and companycode = @HEADERDATA-companycode
and invoicingparty = @HEADERDATA-invoicingparty
and supplierinvoicestatus <> 2
and NOT ( supplierinvoice = @headerdata-supplierinvoice
AND fiscalyear = @headerdata-fiscalyear )
into @DATA(lv_supplier_invoice)
PRIVILEGED ACCESS.

IF sy-subrc = 0.

APPEND VALUE #(
messagetype = if_ex_mrm_check_invoice_cloud=>c_messagetype_error
messageid = 'Z01_READY_EXIST'
messagenumber = '001'
messagevariable1 = |Error al crear documento|
messagevariable2 = |Ya existe un documento con la misma referencia.|
messagevariable3 = lv_reference_value
) TO messages.

ENDIF.

ENDIF.

¿Le ha resultado útil este artículo?