Skip to end of metadata
Go to start of metadata


The purpose of this page is to explain the concept of retention in Invoice Verification.


This document states the business purpose of retention in Logistics Invoice Verification and an example case of setting up and running one cycle.

What is Retention?

Retention is the ability to keep back something. In SAP business process depending on the contracts between purchaser and vendor the purchaser has the authority to retain a portion of the payment for the vendor until the end of warranty period or any other condition agreed upon by purchaser and vendor. This is done in order to mitigate the risk to the purchaser.


Transaction OMR4:

For the retentions a field is offered to define a new document type for the retention document.

Supported are following transactions: MIRA, MIRO, MR8M, MRIS, MRNB, MRRL and BAPI.

OLMR > Incoming Invoice > Retention:

Retention Due Date: customize the due date for retention based on the assigned material group of purchase order. Retention Due Date = Due Date for Net Payment + customized retention runtime.

Retention tax parameter: customize whether the retention document shall be created with tax reduction or not, which is based on the country code.

Retention handling parameters:  customize  

  1. Whether the retention due date shall be mandatory or not during Invoice Verification online process.
    The retention due date is always mandatory for the Invoice Verification automatic process (ERS, IDOC and background) and BAPI.
  2. Special G/L indicator.
  3. Whether the withholding tax shall be considered during the retention process.

Example case

1.Create a purchase order:

At header details under the “Payment Processing Tab” we indicate if retention is relevant for the purchase order. Retention percentage can be populated at header level or item level.

According to selection the retention percentage field is displayed under different tabs:

  • Header level:

  • Item level:


2. Create an invoice:

When you enter the purchase order number the information message M8_2303 appears indicating item is relevant for retention:


(info) Note: Retention indicator’s “H” and “I” are only relevant for retention. Retention is not relevant in the below cases:

1)     Delivery costs invoice items.

2)     Goods returns invoice items.

3)     Free of charge invoice items.

4)     Free goods invoice items.

5)     Statistical PO invoice items.


Retention Due date field is populated in the Invoice header when you enter the reference document.

The Retention Due date will be populated in Invoice Verification online process if at least one line item is relevant for retention. Otherwise this field will not be visible during the online process.

This date is adopted in the invoice item level if no default due date calculation is defined in customizing. If a default date is set, then system calculates the due date based on the customizing entries.

Fields Retention Amount, Retention %, Retention Due Date and Retention Tax Reduction of invoice item data will be always visible. But they are only in display mode and don’t show any information when PO item is not relevant for retention.

3. FI accounting document:

Notice two accounting documents are created: one for the retention and one for normal invoice posting.

Retention accounting document postings:

Notice special G/L indicator “H” and transaction key EGX in this case is used.

The special G/L indicator is read from the customizing setting V_169P_RET in invoice verification. If no one is maintained the system sets special G/L indicator H as default.       

Proposal logic for retention data

1. Retention amount and percentage:

This is received first from the data entered in the Purchase Order and later the check is done for the customer BADI MRM_RETENTIONS implementation. If it exists, the system processes its implementation, whereby user can define default values for retention percentage/amount under his/her own business logic via the method mrm_retentions->change_proposal().


2. Retention tax reduction:

The parameter "retention tax reduction" defines whether the amount of retention document is reduced by the tax portion of the retention or shall be posted net. Its values don’t receive from purchase order, but from the customizing view V_T169RETENTION.


3. Retention due date:

The value of retention due date depends on several elements as the below logic:

a. Invoice Verification does not receive any proposed due date information for retention from purchase order.

b. However, user can define a default due date value via the customizing view V_T169RETTIME.

As shown in the above screen shot, user can customize how long retention can be retained based on each material group, for that material of purchase order has been assigned.

After that, the system will check whether any implementation of BAdI MRM_RETENTIONS is available. If it exists, this BAdI implementation shall be performed, whereby the retention due date can be overwritten by the method mrm_retentions->change_proposal().

Debugging tips

Check for Due date:

Include LMRMCF24

CALL METHOD cl_mrm_retention => due_date 


Calculation of tax:

Checks are done in the subroutine RETENTION_TAB_ITEM_CREATE in the function module MRM_FINAL_CHECK and further tax calculations are done in subroutine RETENTION_ITEM_TAX_CALC.


Withholding tax calculations:

Subroutine retention_acc_paya_item_create.

Based on the customizing view V_169P_RET as below, User can decide whether withholding tax shall be calculated for retention or not.

Related Content

Related Documents


Related SAP Notes/KBAs

Note 1355642 - Security retention & material ledger cannot be used together

Note 1697524 - MIRO: Error message F5701 for security retention

Note 1749187 - MIRO: Security retention amount & amount split or installment payment

Note 1795852 - MIRO: Error message F5 842 for security retention 


  1. Former Member


    Can you please share with us how to block this retention amount line item, because there is no payment term  & due date is zero in the line item. In next payment run system is taking this line item for payment. 

    Thanks in advance.

  2. Hi Lalita,

    I am facing a error while trying to assign and save the GL's for the transaction key EGX in OBYC. Could you kindly advice me the correction also please mention the special GL indicator catgeory to be created or used (noted item with others or down payment request/downpayment) for the Vendor Retention Scenario.


    Thanks in advance.


    1. Hello, 

      Please take a look at the following note if you have access to SMP  715620 Message F5838 for FB08 Reversal with speci If this does not help please open an incident under component FI-AR-AR-C


  3. Former Member


    Dear Piratla

    did you find a solution, i´m having the same message (F5838)- OBYC(EGX)

    Thanks in advance


  4. Dear Sir,


    This document is great.

    Do you have the same Customer Retention function in SD?


    Best Regards,