SAP Knowledge Base Article - Public

3842078 - Material document number not fetched in Supplier Invoice BAdI and date validation fails with backdated GRN entries — SAP S/4HANA Cloud Public Edition

Symptom

  • Material Document Number is not being fetched in the Supplier Invoice BAdI.
  • A validation error occurs when backdated goods receipts (GRN) are booked in the current month, causing the custom rule “Invoice posting date is not before the GRN posting date” to fail.

Environment

  • Product: SAP S/4HANA Cloud Public Edition
  • Fiori UI for Invoice Verification (Public Cloud)

Reproducing the Issue

  1. Create a supplier invoice and assign a purchase order.
  2. Assign invoice line items based on completed goods receipts.
  3. Implement a custom validation in BAdI “Check Invoice Data” that fetches the PO number and queries a CDS view for Material Document items.
  4. Validate that the invoice posting date must not be before the GRN posting date.
  5. Post multiple GRNs on the PO, including backdated entries within the current month.
  6. Attempt to post the invoice and observe that the validation fails and the material document reference is not available to the rule.

Cause

  • The custom validation compares the invoice date against the latest goods-receipt date across all receipts on the PO rather than the goods receipt relevant to the specific invoice line.
  • With multiple GRNs (including earlier backdated ones), an invoice belonging to an earlier GR is wrongly compared to a later GR and rejected.
  • The standard system does not enforce a rule that invoice date must be on/after GR date; only open posting periods are enforced. The behavior comes from the custom rule.

Resolution

  1. Check whether “Goods-Receipt-Based Invoice Verification” is active on the affected PO items (Display Purchase Order – Advanced app, item > Invoice tab).
  2. If GR-based IV is active, adjust the custom logic in BAdI “Check Invoice Data” to compare each invoice line’s posting date with the posting date of the specific goods receipt that the line clears, not the latest GR on the PO.
  3. Ensure the custom check runs on invoice posting only (not when parked or saved as draft).
  4. Exclude invoice lines that do not have a single underlying goods receipt (for example, freight or delivery-cost lines).
  5. If GR-based IV is not active, remove the blocking custom check because a reliable one-to-one link between an invoice line and a specific GR is not available; if needed, use a periodic review report instead of a blocking rule.
  6. Confirm the actual business objective; if it is period control, manage it with standard open posting periods rather than a custom date rule.
  7. Test the adjusted logic with: a single GR, multiple GRs including backdated entries, a freight/delivery-cost line, and a draft invoice to ensure drafts are not blocked.

See Also

Keywords

supplier invoice badi, check invoice data, material document not fetched, backdated grn, goods receipt based invoice verification, gr-based iv, posting date vs gr date, validation failure, cds material document items, multiple goods receipts, invoice posting blocked, parked invoice, freight line exclusion , KBA , MM-FIO-IV-2CL , Fiori UI for Invoice Verification (Public Cloud) , Problem

Product

SAP S/4HANA Cloud Public Edition all versions