IDOC intermediate document
SAP R/3 & ABAP/4 Training
SAP Practice
Enterprise Solutions
What is an IDOC?
• IDOC = Intermediate Document
• IDOC is simply a data container used to exchange
information between any two processes that can understand
the syntax and semantics of the data.
• When we execute an outbound ALE or EDI Process, an
IDOC is created
• In an inbound ALE or EDI process, an IDOC serves as input
to create an application document.
• In the SAP System, IDOCs are stored in database.
• Every IDOC has an unique number(within a client).
What is an IDOC? (contd)
• IDOCs are independent of the sending and receiving systems.
(SAP-to-SAP as well as Non-SAP)
• IDOCs are based on EDI standards, ANSI ASC X12 and EDIFACT. In
case of any conflict in data size, it adopts one with greater length
• IDOCs are independent of the direction of data exchange e.g.
ORDERS01 : Purchasing module : Inbound and Outbound
• IDOCs can be viewed in a text editor. Data is stored in character
format instead of binary format.
IDOC Structure
IDOC Run-Time Components
• An IDOC is an instance of an IDOC Type
• At run time the following events occur
– A unique IDOC no. is allocated by SAP
– One control record is attached to the IDOC
– Segments translate into data records
– Status records are attached
– Syntax rules are checked.
• Each IDOC has 3 parts
– Control Record
– Data Record
– Status Record
• We02 or We05 is used to
display an idoc
IDOC Runtime components (Contd)
• Control Record
– All control record data is stored in EDIDC table. The key to this table is the IDOC
Number
– It contains information like IDOC number,the direction(inbound/outbound), sender,
recipient information, channel it is using, which port it is using etc.
– Direction ‘1’ indicates outbound, ‘2’ indicates inbound.
• Data Record
– Data record contains application data like employee header info, weekly details, client
details etc
– All data record data is stored in EDID2 to EDID4 tables and EDIDD is a structure
where you can see its components.
– It contains data like the idoc number, name and number of the segment in the idoc,
the hierarchy and the data
– The actual data is stored as a string in a field called SDATA, which is a 1000 char long
field.
• Status Record
– Status record are attached to an IDOC at every milestone or when it encounter errors.
– All status record data is stored in EDIDS table.
– Statuses 1-42 for outbound, 50-75 for inbound
IDOC Type:
Basic IDOC Type (we30)
• Basic IDOC Type defines the structure and format of the business
document that is to be exchanged.
• IDOC Type has a
– specific name
– list of permitted segments
– hierarchy of segments
– mandatory/optional segments
– minimum/maximum range of each segment.
Each of these are
segments.
This is the idoc type
These segments have
child segments
IDOC Components :
Segments
• Segment defines the format and structure of a data record. Segments
are reusable components.
• For each segment SAP creates
– Segment Type (version independent)
– Segment Definition (version dependent)
– Segment Documentation
• The last 3 characters is the version of the segment
• Definitions keep changing as per the version but the segment type
remains the same
Extending an Existing IDOC Type
• Used in cases where some additional information is required in addition
to that supplied by the Standard IDOC Type.
• In Transaction WE30 we create the IDOC type as an Extension and
specify the basic type for which it is an extension.
• We add the segments needed as children to existing ones.
• None of the Reference Segments can be deleted or changed.
Basic Type(ORDERS01)
F1
Cannot be modified
F2
F3
Extension Child Segs
F4
F5
Message Types
• A message represents a specific type of document that is transmitted
between two partners eg. Orders,orders responses,invoices etc
• An idoc type can be associated with many message types
• Also a message type can be associated with different idoc types
Partner Profiles
• A partner is defined as a business partner with whom you conduct
business and exchange documents
• The concept of partner profile is quite similar
• In the partner profile of a partner that we exchange Idocs with, we
maintain the parameters that are necessary for exchanging the data.
• The transaction used is We20. We will look at this again while dealing
with outbound and inbound processes.
IDOC Type Documentation
• Each IDOC in the system is thoroughly documented (we60)
Where and How an IDOC is created?
• Lets take an example to understand this:
• Whenever a Purchase Order (PO) is created we want to send the IDOC
to a vendor.
• The PO is sent in the form of an IDOC to the vendor (partner). That
partner has to be EDI enabled in that system. SAP should realize that it
could send doc to this vendor electronically.
• The PO sent as an outbound idoc by the customer will be inbound idoc
for the vendor. The SAP system on the vendors side can process this
to create an application document (a sales order) on their system.
• Quotation, RFQ, PO, SO, Invoice, delivery note etc are some of the
commonly exchanged documents through IDOC
The Outbound Process
• Steps involved in creating an outbound idoc
– Create segments
– Create an idoc type
– Create a message type (we81)
– Associate a message type to idoc type(we82)
– Create a port(we21)
– If you are going to use the message control method to trigger idocs then create the
function module for creating the idoc and associate the function module to an
outbound process code
– Otherwise create the function module or stand alone program which will create the
idoc
– Create a partner profile with the necessary information in the outbound parameters for
the partner you want to exchange the idoc with.
– Trigger the idoc.
Creating the message type
• WE81
Associating the message type and the idoc type
• WE82
Creating the port
• WE21
Creating the function module/program to create the idoc
• If using message control make a copy of any of the standard function
modules that are named “IDOC_OUTPUT*”, where * is _<msgtyp>.
Follow this naming convention.
• The function module interface
Importing
OBJECT Complete current NAST record which contains the key of the object to be
extracted
CONTROL_RECORD_IN Control record pre-filled with information that is known to the calling program
like the sender system
Exporting
OBJECT_TYPE Document category for definition of transaction/event. Business object name
CONTROL_RECORD_OUT Extended control record with sender information (message type, direction, idoc
type, receiver type and name)
Tables
INT_EDIDD Internal table for Idoc. Data records to be filled in the same order that is in the
idoc type definition.
• If creating a stand alone program/FM without message control then FM
‘MASTER_IDOC_DISTRIBUTE’ should be called for creating the idoc
after populating the control record and the data records.
Creating Outbound Process Code (WE41)
• What is Process Code ?
Process of filling the IDOC with application data is done by Function
Module. But, function module is not assigned to a Partner. It is
encapsulated by a Process Code and this Process Code is assigned to
a Partner in Partner Profile.
• Assigning Function Module to Process Code
- Go to Transaction WE41.
- Switch to “Change” Mode and click “New Entries”.
- Enter Process Code Name and assign the Function Module created.
- In the view VEDI_TMSG1 associate the process code and the
message type to get F4 help in the partner profile
Process Code
Partner
Function Module
Snapshot of WE41
Creating Partner Profile (WE20)
• Partner Profile
We must maintain the business partners with whom we communicate
via IDocs, in Partner Profiles.
• Steps to create Partner Profile
- Goto Transaction WE20.
- Click on Create Button.
- Enter the Partner Number and partner type.
- Save the Data.
- For Outbound Partner Profile we have to create Outbound
Parameters. Press the “add entry” button under outbound parameters.
- Specify Partner Function, Message type created, Port (create a port in
WE21),Basic Type and Output Mode.
- If using message control, goto “Message Control” Tab and link the
Message Type and Process Code created.
- Save.
WE20
Function module - Interface
• An example interface to post a sales order
Import parameters Reference structure Expalnation
INPUT_METHOD BDWFAP_PAR- Describes how the
INPUTMETHD function module is to
be processed –
background or
foreground
MASS_PROCESSING BDWFAP_PAR- Flag – indicates
MASS_PROC mass inbound
processing
Creating a partner profile -- Tcode we20
• Message type – Entry to be created under Inbound parameters
• Process code
• Note that no other details are needed unlike partner profile for outbound
process
• Enter partner function(optional)
Testing the inbound function module – we19
• Use can create an idoc starting from a blank template using the basic
type or the message type or you can use an existing idoc
• Change values if required
• Post the idoc
– Use inbound function module or
– Standard inbound function module
• You can use “inbound function module” and call in debugging mode to
debug the function module