IDocs & ALE

Key terms: message type (business meaning, e.g.

28.1 Concepts

IDoc (Intermediate Document): SAP's standard asynchronous message container for EDI and system-to-system integration.

ALE (Application Link Enabling): distributes data between SAP systems using IDocs (e.g. master data from a central system).

EDI: IDocs exchanged with external partners via middleware (SAP PI/PO, SAP Integration Suite).

28.2 IDoc structure

IDoc number, type, message type, sender/receiver, direction Segments (hierarchical) with business data EDID4 (EDIDD structure) Processing history (status codes)

Key terms: message type (business meaning, e.g. ORDERS, MATMAS, DEBMAS, INVOIC), basic type (structure version, e.g. ORDERS05, MATMAS05), extension (customer segments Z1…), segment (E1EDK01).

Important status codes: outbound 03 (passed to port OK), 30 (ready for dispatch), 02/29 (errors); inbound 53 (application document posted), 51 (application error), 64 (ready to be passed to application).

28.3 Configuration objects

IDoc types / segments Message types / link to basic type Partner profiles (inbound/outbound parameters, process codes) Outbound / inbound process codes IDoc display / list Test tool (copy & reprocess IDocs) Send material / customer master

28.4 Creating an outbound IDoc

DATA: ls_control TYPE edidc,
      lt_data    TYPE STANDARD TABLE OF edidd,
      lt_comm    TYPE STANDARD TABLE OF edidc,
      ls_seg     TYPE z1order_header.           " custom segment structure

ls_control = VALUE #( mestyp = 'ZORDER' idoctp = 'ZORDER01'
                      rcvprt = 'LS' rcvprn = 'EXTSYS100' ).

ls_seg = VALUE #( order_id = ls_order-order_id customer = ls_order-customer ).
APPEND VALUE #( segnam = 'Z1ORDER_HEADER' sdata = ls_seg ) TO lt_data.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
  EXPORTING
    master_idoc_control        = ls_control
  TABLES
    communication_idoc_control = lt_comm
    master_idoc_data           = lt_data
  EXCEPTIONS
    error_in_idoc_control      = 1
    error_writing_idoc_status  = 2
    error_in_idoc_data         = 3
    OTHERS                     = 4.
IF sy-subrc = 0.
  COMMIT WORK.                                  " IDoc is dispatched after commit
ENDIF.

28.5 Inbound processing

An inbound function module (interface like IDOC_INPUT_ORDERS) receives IDOC_CONTRL, IDOC_DATA, returns IDOC_STATUS and RETURN_VARIABLES. Register it with WE57 (FM ↔ IDoc type), BD51 (input type), and WE42 (process code). Loop over the data records, CASE segnam, move sdata into the segment structure, post via BAPI, and append status 53 or 51.

Modern alternatives for new integrations: OData/REST APIs, SOAP services, SAP Event Mesh / Advanced Event Mesh with RAP business events, and SAP Integration Suite.