SAP BAPIObjectBAPI_GOODSMVT_GETDETAILModuleMM_P2P

BAPI_GOODSMVT_GETDETAIL — Read Details of a Posted Material Document

BAPI_GOODSMVT_GETDETAIL is a read-only BAPI that returns the header and item data of a material document already posted in the system, mirroring transaction MB03. It takes the material document number and fiscal year as keys and hands back the goods movement details exactly as stored; it cannot change, reverse, or repost anything.

Covers how BAPI_GOODSMVT_GETDETAIL retrieves the header and line-item detail of an existing material document, the keys it requires, and why the fiscal year parameter matters as much as the document number. Focuses on the RETURN handling mistakes that cause interfaces to treat a missing document as a valid empty one, and where this call fits against its sibling create and cancel BAPIs.

Published 16 Sept 2026· 1,033 words

What it does

BAPI_GOODSMVT_GETDETAIL retrieves the header and item data of a material document that has already been posted, regardless of which movement type created it — goods receipt, goods issue, transfer posting, or physical inventory difference. It mirrors the read side of transaction MB03 (Display Material Document), not MB01 or MIGO in create mode. Given a material document number and the fiscal year it belongs to, it returns the header attributes and the full set of line items exactly as stored, with no option to change or reverse the document through this call. It functions as a lookup: confirming what actually got posted after a goods movement, reconciling an interface's own record of a movement against SAP, or pulling movement detail into a monitoring or exception-handling program without touching the document itself.

Important parameters

  • MATERIALDOCUMENT - the material document number to retrieve, mandatory import parameter
  • MATDOCUMENTYEAR - the fiscal year the document was posted in, mandatory import parameter; material document numbers are reused across years so this field, not the number alone, disambiguates the document
  • GOODSMVT_HEADRET - export structure carrying header-level data such as posting date, document date, entering user, and header text
  • GOODSMVT_ITEMS - export table carrying the item-level detail of the document: material, plant, storage location, movement type, quantity, unit of measure, batch, and related account assignment fields where relevant
  • RETURN - standard BAPIRET2-style table carrying success, warning, or error messages, most commonly used to report that the requested document could not be found

Commit behaviour

There is nothing to commit. This BAPI only reads data, so calling BAPI_TRANSACTION_COMMIT afterward has no effect and forgetting it causes no data loss because no database change was ever made. The commit concern that matters here runs the other way: if this BAPI is called immediately after BAPI_GOODSMVT_CREATE in a separate call or a separate logical unit of work, and the creating program has not yet issued its own commit, the document may not be visible to the read yet. That shows up as a spurious document-not-found result rather than a commit failure on this BAPI's own side, and it is easy to misdiagnose as a bug in GETDETAIL when the real cause is timing on the creating process.

Return handling

RETURN must be scanned for TYPE equal to E or A before anything in GOODSMVT_HEADRET or GOODSMVT_ITEMS is trusted. The common lazy pattern — checking only whether RETURN is empty — fails here because a document-not-found condition, a wrong fiscal year, or an authorization gap all populate RETURN with an error message while leaving the export structures blank rather than raising an exception. A program that skips the RETURN check and reads the empty header structure will see blank posting dates and zero quantities and treat them as real data instead of as a failed lookup. This produces false negatives in reconciliation jobs: a movement that genuinely posted gets reported as missing, or worse, a movement that never posted gets silently treated as a zero-quantity movement and passed downstream. The fix is always the same discipline as with any BAPI: check TYPE first, branch on E/A before touching the export tables, and log the MESSAGE text rather than discarding it, since it usually states plainly whether the document number, the year, or the authorization was the problem.

ECC vs S/4HANA

This BAPI remains valid and supported on S/4HANA for reading posted material document detail. The underlying storage of movement data changed with the consolidated material document table, but the BAPI layer insulates callers from that change, so existing interfaces built on this call do not need rework for that reason alone. No specific successor API has been announced to replace it for this read scenario, and it remains the standard choice where no dedicated OData or API Business Hub service covers the same lookup.

Common pitfalls

  • Passing the current calendar year instead of the actual posting year for MATDOCUMENTYEAR, which fails silently as document-not-found around fiscal year-end when documents from the prior year are still being processed
  • Calling this BAPI right after a create BAPI in the same transaction without confirming the create was committed, leading to intermittent not-found results that look like a data problem but are a timing problem
  • Assuming GOODSMVT_ITEMS returns exactly one row; multi-line goods movements return multiple item rows and interfaces built for a single-item assumption drop or overwrite data
  • Ignoring that a reversed or cancelled material document still returns successfully from this BAPI with its original data; the BAPI does not flag cancellation status in an obvious place, so downstream logic that assumes existence equals validity gets fooled
  • Treating an empty RETURN plus blank header fields as a valid zero-quantity movement instead of a failed lookup, because the RETURN check was skipped

Whose problem this is

This sits with the interface developer first, since failures are almost always a wrong key (document number, year) or a RETURN check that was never coded. Functional involvement is needed only when the returned data itself is in question — for example, if a document appears to be missing or its quantities look wrong — in which case functional should confirm the document's actual status in MB03 before the developer is asked to change anything.

Related SAP objects

Reviewed pages this object connects to in the ERPClimb knowledge graph.

Source: ERPClimb — https://erpclimb.com/sap-bapis/bapi-goodsmvt-getdetailERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.