---
description: IDOC stands for Intermediate Document When we execute an outbound ALE or EDI Process, an IDOC is created. T-code used are WE02, WE05, WE30, WE31, WE60, WE81, WE20
title: "SAP IDOC Tutorial in ABAP: Step-by-Step Guide"
image: https://www.guru99.com/images/idocdefinition-architecture-implementation.png
---

[Skip to content](#main)

**⚡ Smart Summary**

SAP IDoc (Intermediate Document) is a standardized data container that moves business information between SAP and non-SAP systems through ALE and EDI. This tutorial explains its definition, structure, types, tables, partner profiles, ports, and the end-to-end Outbound and Inbound processes.

- 📦 **Core Definition:** IDoc is a system-neutral data container based on EDI standards such as ANSI ASC X12 and EDIFACT.
- 🧱 **Three-Part Structure:** Every IDoc consists of a Control Record, Data Records, and Status Records, each stored in dedicated database tables.
- 🆚 **Type Hierarchy:** Basic IDoc Types ship with SAP and cannot be modified; Extension Types add custom fields when required.
- 🔁 **Process Flows:** Outbound creates and sends IDocs; Inbound receives and posts them through linked function modules.
- 🤖 **AI Enablement:** AI-driven monitoring tools detect IDoc failures early and auto-map fields across SAP and non-SAP partners.

Read More

![SAP IDOC Tutorial](https://www.guru99.com/images/idocdefinition-architecture-implementation.png)

## What is an IDoc?

IDoc is **simply a data container** used to exchange information between any two processes that can understand the syntax and semantics of the data.

In other words, an IDoc is like a data file with a specified format which is exchanged between two systems that know how to interpret that data.

IDoc stands for “**Intermediate Document**“.

When you execute an **outbound** ALE or EDI process, an IDoc is created. In the [SAP System](https://www.guru99.com/what-is-sap-definition-of-sap-erp-software.html), IDocs are stored in the database, and every IDoc has a **unique number** within a client.

**Key Features**

- IDocs are **independent of the sending and receiving systems** (SAP-to-SAP as well as non-SAP).
- IDocs are based on [EDI](https://www.guru99.com/what-is-edi-ale-and-idoc.html) standards, ANSI ASC X12, and EDIFACT. In case of any conflict in data size, IDoc adopts the one with greater length.
- IDocs are **independent of the direction of data exchange**, e.g. ORDERS01 in the Purchasing module supports both Inbound and Outbound.
- IDocs can be viewed in a **text editor** because the data is stored in character format instead of binary format.

## Structure of an IDoc

[![Structure of an IDoc]()](https://www.guru99.com/images/sap/2011/01/idoc-structure.png)

The IDoc structure consists of three parts:

1. **The administration part (Control Record)** — holds the type of IDoc, message type, current status, sender, receiver, and similar metadata. This is referred to as the Control Record.
2. **The application data (Data Record)** — contains the business data. These are called the data records or **segments**.
3. **The status information (Status Record)** — provides information about the various stages the IDoc has passed through.

You can view an IDoc using transaction **WE02** or **WE05**.

[![IDoc record showing Control, Data and Status]()](https://www.guru99.com/images/sap/2011/01/3.png)

As seen in the screenshot above, the IDoc record has three parts — Control, Data, and Status. Each part is explored in detail below.

**Control Record**

- All Control Record data is stored in the **EDIDC** table. The key to this table is the IDoc Number.
- It contains information like IDoc number, direction (inbound/outbound), sender, recipient information, channel in use, and port in use.
- Direction “1” indicates outbound and “2” indicates inbound.

**Data Record**

- The Data Record contains application data such as employee header info, weekly details, client details, and so on.
- All Data Record data is stored in tables **EDID2 to EDID4**, and **EDIDD** is a structure where you can see its components.
- It contains data like the IDoc number, the name and number of the segment in the IDoc, the hierarchy, and the data itself.
- The actual payload is stored as a string in a field called **SDATA**, which is a 1000-character field.

**Status Record**

- A Status Record is attached to an IDoc at every milestone or when it encounters an error.
- All Status Record data is stored in the **EDIDS** table.
- Statuses 1–42 are for outbound while 50–75 are for inbound.

**Don't Miss:**

- [SAP ABAP Internal Table: Create, Read, Populate, Copy & Delete](https://www.guru99.com/all-about-sap-internal-tables.html)
- [SAP ABAP Table Control with Examples](https://www.guru99.com/abap-table-controls.html)
- [SAP ABAP Report Programming](https://www.guru99.com/all-about-abap-report-programming.html)
- [Difference Between User Exit and Customer Exit in SAP](https://www.guru99.com/what-is-user-and-customer-exits.html)

## IDoc Types

An IDoc Type (Basic) defines the structure and format of the business document to be exchanged. **An IDoc is an instance of an IDoc Type**, just like the concept of variables and variable types in [programming languages](https://www.guru99.com/best-programming-language.html). IDoc Types can be defined using transaction **WE30**.

## What is a Segment?

A Segment defines the format and structure of a **Data Record** in an IDoc. Segments are reusable components.

For each segment, SAP creates the following components.

- Segment Type (version independent)
- Segment Definition (version dependent)
- Segment Documentation

The last three characters represent the version of the segment. Definitions can change as the version changes, but the Segment Type remains the same. Transaction: **WE31**.

[![Segment in IDoc]()](https://www.guru99.com/images/sap/2011/01/4.png)

## What is an Extension IDoc Type?

An IDoc is of two types:

1. Basic
2. Extension

[![Basic and Extension IDoc types]()](https://www.guru99.com/images/sap/2011/01/5.png)

SAP provides many pre-defined Basic IDoc Types which **cannot be modified**. If you need to add more data to a restricted Basic Type, you can use an Extension Type. Most of the time you will **not** need extensions.

[![Extension IDoc type illustration]()](https://www.guru99.com/images/sap/2011/01/6.png)

## Documentation

Each IDoc is thoroughly documented in transaction **WE60**.

[![IDoc Documentation in WE60]()](https://www.guru99.com/images/sap/2011/01/7.png)

## Message Type

A message represents a specific type of document that is transmitted between two partners, for example Orders, Order Responses, and Invoices.

An IDoc Type can be associated with many Message Types. Conversely, a Message Type can be associated with different IDoc Types. Transaction: **WE81**.

[![Message Type in IDoc]()](https://www.guru99.com/images/sap/2011/01/10.png)

## IDoc Views

An IDoc Type can be used for more than one Message Type, which results in IDocs containing more fields than required for a particular Message Type.

IDoc Views improve performance in generating IDocs by ensuring that only the relevant segments are filled with data. IDoc Views are important only for Outbound Processing.

[![IDoc Views]()](https://www.guru99.com/images/sap/2011/01/8.png)

## Partner Profiles

A partner is a business partner with whom you conduct business and exchange documents.

In the partner profile of a partner with whom IDocs are exchanged, you maintain the parameters that are necessary for exchanging the data. The transaction used is **WE20**.

[![Partner Profiles in IDoc]()](https://www.guru99.com/images/sap/2011/01/9.png)

## Port

The Port defines the technical characteristics of the connection between your SAP system and the other system you want to transfer data with (subsystem). The Port defines the medium in which data is exchanged between the two systems.

There are different types of ports. The two most commonly used are **TRFC ports** used in ALE and **File ports** used by EDI.

For TRFC ports, you have to give the name of the logical destination created using **SM59**. When using a File port, you can specify the directory where the IDoc file should be placed. The other system or middleware then picks up the file from there. A function module can be used to generate a file name for the IDoc. While [testing](https://www.guru99.com/software-testing.html), you can use “Outbound file” to specify a constant file name. The tab “**outbound trigger**” can be used to supply information if you want to trigger some processing on the subsystem when an IDoc is created at this location. Specify the command file name and the directory that must be run.

[![Port in IDoc]()](https://www.guru99.com/images/sap/2011/01/111.png)

## Common IDoc Transaction Codes

| Transaction Code | Purpose |
| --- | --- |
| WE02 / WE05 | Display and monitor IDocs |
| WE30 | Create or change IDoc Type |
| WE31 | Create or change Segment |
| WE20 | Maintain Partner Profile |
| WE21 | Maintain Ports |
| WE42 | Define inbound Process Code |
| WE57 | Allocate inbound function module to Message Type |
| WE60 | IDoc Documentation |
| WE81 / WE82 | Create Message Type / associate to IDoc Type |
| BD51 | Define function module characteristics |
| SM59 | Maintain RFC destinations |

## IDoc Process: A Real-World Example

Consider the example of sending a Purchase Order to a vendor through IDoc.

- Whenever a Purchase Order (PO) is created, the system needs to send an IDoc to the vendor.
- The PO is sent in the form of an IDoc to the vendor (partner). That partner has to be EDI enabled in the system. SAP recognizes that it can send the document to this vendor electronically.
- The PO sent as an outbound IDoc by the customer becomes an inbound IDoc for the vendor. The SAP system on the vendor’s side can process this to create an application document (a Sales Order) on their system.
- Quotations, RFQs, POs, SOs, Invoices, and Delivery Notes are some of the most commonly exchanged documents through IDoc.

The process of data transfer out of your SAP system is called the **Outbound process**, while data moving into your SAP system is called the **Inbound process**. As a developer or consultant who sets up these processes for your organization, the steps to configure each are detailed below.

## The Outbound Process

Steps involved:

1. Create segments (WE31).
2. Create an IDoc Type (WE30).
3. Create a Message Type (WE81).
4. Associate the Message Type with the IDoc Type (WE82).
5. Create a Port (WE21).
6. If you use the message-control method to trigger IDocs, create the function module that builds the IDoc and link it to an outbound Process Code.
7. Otherwise, create a function module or stand-alone program that creates the IDoc directly.
8. Create a Partner Profile (WE20) with the necessary information in the outbound parameters for the partner you exchange the IDoc with, and trigger the IDoc.

## The Inbound Process

Steps involved:

1. Create the Basic IDoc Type (Transaction WE30).
2. Create the Message Type (Transaction WE81).
3. Associate the Message Type with the Basic IDoc Type (Transaction WE82).
4. Create the function module for processing the IDoc.
5. Define the function module characteristics (BD51).
6. Allocate the inbound function module to the Message Type (WE57).
7. Define the Process Code (Transaction WE42).
8. Create the Partner Profile (Transaction WE20).

## FAQs

⚡ What is the difference between IDoc and [BAPI](https://www.guru99.com/all-about-bapi.html) in SAP?

IDoc is asynchronous, used for system-to-system messaging via ALE or EDI. BAPI is synchronous, used for real-time access to SAP business objects. IDoc is queued; BAPI returns immediately.

🧱 What is the difference between an IDoc Type and a Message Type?

An IDoc Type defines the technical structure of segments and fields. A Message Type defines the business meaning, such as Orders or Invoices. One IDoc Type can serve many Message Types and vice versa.

🔍 How do I check the status of an IDoc in SAP?

Use transaction WE02 or WE05 to display IDocs and inspect status records. Outbound uses status codes 1–42; inbound uses 50–75. Transaction BD87 reprocesses errored IDocs.

📏 What is the maximum size of an IDoc data field?

The SDATA field that stores the payload in each data record is 1000 characters long. An IDoc can contain many data records, so total payload scales with the number of segments.

🌐 Can IDocs be exchanged between SAP and non-SAP systems?

Yes. IDocs are system-neutral and follow EDI standards such as ANSI ASC X12 and EDIFACT. Non-SAP systems can produce or consume IDoc files through File ports or middleware like SAP PI/PO.

🗄️ Where are IDocs stored in the SAP database?

Control records sit in table EDIDC, data records in EDID2 to EDID4, and status records in EDIDS. The IDoc number is the key linking all three tables for a given IDoc.

🤖 How does AI improve IDoc error handling in SAP?

AI-powered monitoring tools cluster recurring IDoc errors, predict failures from historical patterns, and recommend fixes for status 51 or 56 issues, cutting manual reprocessing time significantly.

🧠 Can AI automate IDoc field mapping in SAP integrations?

Yes. AI-driven mapping engines compare segment definitions across SAP and partner systems, propose field mappings, and learn from past corrections — sharply reducing manual configuration in ALE and EDI projects.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.**

##### Sign up for the newsletter

Subscribe for Free

You have successfully subscribed.  
Please check your inbox.

![AI-Newsletter]() Chosen by over **350,000+** professionals

[Scroll to top](#wrapper)

×

Search for:

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/idocdefinition-architecture-implementation.png","url":"https://www.guru99.com/images/idocdefinition-architecture-implementation.png","width":"650","height":"250","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/all-about-idocdefinition-architecture-implementation.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/abap-tutorial","name":"SAP - ABAP"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/all-about-idocdefinition-architecture-implementation.html","name":"SAP IDOC Tutorial in ABAP: Step-by-Step Guide"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/all-about-idocdefinition-architecture-implementation.html#webpage","url":"https://www.guru99.com/all-about-idocdefinition-architecture-implementation.html","name":"SAP IDOC Tutorial in ABAP: Step-by-Step Guide","dateModified":"2026-10-09T13:55:55+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/idocdefinition-architecture-implementation.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/all-about-idocdefinition-architecture-implementation.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/editorial","name":"Editorial Team","url":"https://www.guru99.com/author/editorial","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/favicon-new-logo.png","url":"https://www.guru99.com/images/favicon-new-logo.png","caption":"Editorial Team","inLanguage":"en-US"},"sameAs":["https://www.guru99.com/editorial-team"],"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"SAP - ABAP","headline":"SAP IDOC Tutorial in ABAP: Step-by-Step Guide","description":"IDOC stands for Intermediate Document When we execute an outbound ALE or EDI Process, an IDOC is created. T-code used are WE02, WE05, WE30, WE31, WE60, WE81, WE20","keywords":"sap-abap, sap","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/editorial","name":"Editorial Team"},"dateModified":"2026-10-09T13:55:55+05:30","image":{"@id":"https://www.guru99.com/images/idocdefinition-architecture-implementation.png"},"copyrightYear":"2026","name":"SAP IDOC Tutorial in ABAP: Step-by-Step Guide","subjectOf":[{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the difference between IDoc and BAPI in SAP?","acceptedAnswer":{"@type":"Answer","text":"IDoc is an asynchronous data container used for system-to-system messaging via ALE or EDI. BAPI is a synchronous function-module API used for real-time access to SAP business objects. IDoc is queued; BAPI returns immediately."}},{"@type":"Question","name":"What is the difference between an IDoc Type and a Message Type?","acceptedAnswer":{"@type":"Answer","text":"An IDoc Type defines the technical structure of segments and fields. A Message Type defines the business meaning of the document, such as Orders or Invoices. One IDoc Type can serve many Message Types and vice versa."}},{"@type":"Question","name":"How do I check the status of an IDoc in SAP?","acceptedAnswer":{"@type":"Answer","text":"Use transaction WE02 or WE05 to display IDocs and inspect their status records. Outbound IDocs use status codes 1-42 and inbound IDocs use status codes 50-75. Transaction BD87 is used to reprocess errored IDocs."}},{"@type":"Question","name":"What is the maximum size of an IDoc data field?","acceptedAnswer":{"@type":"Answer","text":"The SDATA field that stores the actual payload in each data record is 1000 characters long. An IDoc can contain many data records, so the total payload scales with the number of segments rather than a single field length."}},{"@type":"Question","name":"Can IDocs be exchanged between SAP and non-SAP systems?","acceptedAnswer":{"@type":"Answer","text":"Yes. IDocs are system-neutral and follow EDI standards such as ANSI ASC X12 and EDIFACT. Non-SAP systems can produce or consume IDoc files through File ports or middleware such as SAP PI/PO and OpenText."}},{"@type":"Question","name":"Where are IDocs stored in the SAP database?","acceptedAnswer":{"@type":"Answer","text":"Control records sit in table EDIDC, data records in tables EDID2 to EDID4, and status records in table EDIDS. The IDoc number is the key that links all three tables together for a given IDoc."}},{"@type":"Question","name":"How does AI improve IDoc error handling in SAP?","acceptedAnswer":{"@type":"Answer","text":"AI-powered monitoring tools cluster recurring IDoc errors, predict failures from historical patterns, and recommend fixes for status 51 or 56 issues. They cut manual reprocessing effort and shorten mean time to recovery."}},{"@type":"Question","name":"Can AI automate IDoc field mapping in SAP integrations?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI-driven mapping engines compare segment definitions across SAP and partner systems, propose field mappings, and learn from past corrections. This reduces manual configuration time in ALE and EDI projects significantly."}}]}],"@id":"https://www.guru99.com/all-about-idocdefinition-architecture-implementation.html#schema-1101967","isPartOf":{"@id":"https://www.guru99.com/all-about-idocdefinition-architecture-implementation.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/all-about-idocdefinition-architecture-implementation.html#webpage"}}]}
```
