EDI_DOCUMENT_OPEN_FOR_CREATE — Opening an IDoc for segment-by-segment creation
EDI_DOCUMENT_OPEN_FOR_CREATE is a low-level building block of the classic IDoc interface that allocates a new IDoc document and initializes its control record before segments are appended one at a time. It predates ALE distribution and BAPI-to-IDoc generation, is used internally and by legacy custom programs, and is not a supported public API for new development.
This page covers EDI_DOCUMENT_OPEN_FOR_CREATE, the function module that opens a new IDoc for segment-by-segment construction inside the classic EDI/IDoc interface. It focuses on how the control record is populated, what the exceptions actually mean when a program creating an IDoc this way fails silently, and why almost no new development should touch this API directly.
Published 16 Sept 2026· 1,146 words
What it does
EDI_DOCUMENT_OPEN_FOR_CREATE belongs to the older, segment-oriented layer of the IDoc interface that existed before ALE distribution models and BAPI-based IDoc generation became the standard route. It allocates a document number, writes the initial control record, and puts the IDoc into a state where data segments can be appended one after another by companion function modules, ending with a close call that finalizes the document and triggers status handling. It is used internally by parts of the classic interface and occasionally by custom programs that need to build an outbound or file-based IDoc by hand, for example when integrating with a subsystem that expects raw IDoc segment structures rather than a BAPI-mapped payload. It is not published as a stable customer-facing API; SAP's supported path for generating IDocs is ALE distribution or BAPI-to-IDoc conversion, and this module should be treated as an internal mechanism rather than a design pattern for new interfaces.
Parameters
The interface centers on a control-record-style structure similar to the standard IDoc control record (EDIDC), carrying fields such as message type, basic IDoc type and extension, sender and receiver port, sender and receiver partner number and type, and direction. On successful open the function returns the allocated document number that every subsequent segment-append and the closing call must reference. There is typically a client indicator implied by the calling session rather than passed explicitly. Any field left blank in the control record at open time (partner, message type, IDoc type) generally has to be resolved before the document can be closed successfully, because the close step validates the record against partner profile and IDoc type definitions.
- control record structure carrying message type, IDoc type/extension, sender and receiver port and partner
- returned document number used by all subsequent segment-append calls
- direction indicator (outbound versus inbound) embedded in the control record
- no return of a populated segment buffer at this stage - the document is empty until segments are appended
Exceptions
Failures at open time fall into a few real categories rather than abstract technical errors. One class signals that the requested basic IDoc type or extension does not exist in the system, which means the control record was built with a typo or a type that was never activated - swallowing this leaves the caller with no document number and any later segment-append call will simply fail against a nonexistent reference. Another class signals that the partner or port referenced in the control record is not valid for the given direction, which almost always traces back to an incomplete or wrong partner profile rather than a bug in the calling program. A third class is a generic internal or communication failure, which in practice means the open call could not obtain a document number, often during a system state where number range buffering or the EDI subsystem tables are locked or inconsistent. Ignoring any of these and proceeding to append segments against an undefined document number produces orphaned or corrupt IDoc shells that show up later as unexplained short dumps or stuck documents rather than a clean error at the point of failure.
How to call it safely
The call is always the first step of a three-part sequence: open, append one or more segments in order, then close. The returned document number must be checked and stored before any append call is made; a program that ignores the open call's exception and continues into the append loop anyway will either dump or silently build segments against a stale or zero document number. After the close call, the resulting IDoc status and control record should be re-read from the database rather than assumed, because the close step is where partner profile and syntax validation actually happen and where the document can still be rejected even though the open call succeeded. Wrapping the whole open-append-close sequence in a single logical unit of work, with a rollback path on any exception, avoids leaving half-built IDoc shells behind.
ECC vs S/4HANA
This module is part of the classic, pre-ALE EDI interface and has no S/4HANA-specific enhancement or Fiori equivalent; it behaves the same way on ECC and S/4HANA where the classic IDoc interface is still present. It sits well outside the clean-core model: any custom program that still calls it directly for new integration scenarios should be flagged during an S/4HANA move for replacement with ALE distribution, BAPI-to-IDoc mapping, or an integration-suite-based approach rather than migrated as-is. SAP has not published a released successor because the recommended pattern was already ALE/BAPI-based IDoc generation long before S/4HANA existed.
Common pitfalls
Most real incidents trace back to a small set of habits rather than the function module itself.
- Calling open without checking the exception and proceeding to append segments against a document number that was never allocated, producing dumps deep inside the append call that are hard to trace back to the real cause
- Populating the control record with a message type or IDoc type that exists in the sending system but was never activated or linked to a partner profile in the receiving client, so the open call fails only in that environment
- Reusing a hardcoded direction or port value copied from an unrelated interface, which passes the open call but causes the close step to reject the document against partner profile checks
- Treating this function module as a template for new custom interfaces instead of using ALE distribution or BAPI-to-IDoc generation, which multiplies the maintenance burden every time the underlying IDoc type changes
- Building segments in the wrong hierarchical order relative to the IDoc type definition, which the open call cannot detect and which only surfaces as a syntax error at close time
Whose problem this is
This is an ABAP development and integration problem, not a functional configuration one. When it appears in a stack trace or dump, the interface developer who owns the custom program calling it is responsible for the fix; basis or functional teams should only be involved if the underlying issue turns out to be a missing partner profile, port definition, or IDoc type activation.
Related SAP objects
Reviewed pages this object connects to in the ERPClimb knowledge graph.
Source: ERPClimb — https://erpclimb.com/sap-function-modules/edi-document-open-for-createERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.