Ads

IDOC in SAP ABAP

What is an IDOC in SAP ABAP

What is a IDOC?
Idoc in SAP ABAP is important tool which is used to exchange docs between two different process that modules in the idoc format.In this lesson ,we are going to learn what is an idoc and its definition and how to create idoc and importand idoc transactions
An IDoc is simply a data container that is used to exchange information between any two processes that can understand the syntax and semantics of the data. IDoc is not a process.
     IDocs are stored in the database.
     In the SAP system, IDocs are stored in database tables.
     IDocs are independent of the sending and receiving systems.
     IDocs are independent of the direction of data exchange.


What is an EDI and ALE: 


IDocs are text encoded documents with a rigid structure that are used to exchange data between R/3 and a foreign system.Therefore an IDoc data exchange is always an asynchronous process.

The significant difference between simple RFC-calls and IDoc data exchange is the fact, that every action performed on IDocs are protocolled by R/3 and IDocs can be reprocessed if an error occurred in one of the message steps.

While IDocs have to be understood as a data exchange protocol, EDI and ALE are typical use cases for IDocs.

R/3 uses IDocs for both EDI and ALE to deliver data to the receiving system.

The difference between EDI and ALE can be defined  ,If we send data to an external partner, we generally using EDI, while ALE is a mechanism to reliable replicate data between trusting systems to store a redundant copy of the IDoc data.


Difference between ALE and EDI 


ALE is used to support distributed yet integrated processes across several SAP systems whereas EDI is used for the exchange of business documents between the systems of business partners ALE is SAP's technology for supporting a distributed environment whereas EDI is a process used for exchange of business documents which now have been given a standard format Both ALE and EDI require data exchange.

In simple words , an idoc is like a data file with a specified format which is exchanged between 2 systems which know how to interpret that data.

IDOC stands for " Intermediate Document" When we execute an outbound ALE or EDI Process, an IDOC is created.

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.
EDI (Electronic Document interchange) - EDI is the electronic exchange of business documents between the computer systems of business partners, using a standard format over a communication network.
EDI is also called paperless exchange.


 Idoc Advantages:

Reduced Data entry errors
Reduced processing time
Availability of data in electronic form
Reduced paperwork
Reduced Cost
Reduced inventories and better planning
Standard means of communications
Better business process

EDI has two process
1. Outbound process
2. Inbound process

Outbound Process:

1.Application document is created.
2. IDOC is generated
3.Idoc is transferred from SAP to Operating system layer
4.Idoc is converted into EDI standards
5.Edi document is transmitted to the business partner
6.The Edi Subsystem report status to SAP

Inbound Process:

1.EDI transmission received
2.EDI document is converted into an IDOC
3.IDOC is transferred to the SAP layer
4.The application document is created
5.The application document can be viewed.

 IDOC:
IDOC is a container that can be used to exchange data between any two processes.
Each IDOC is assigned a unique number for tracking and future reference.

IDOC consists of several segments, and segments contain several fields.

IDOC contains the following three types of records...

1. One Control Record.
2. One or many Data Record
3. One or many Status record


PORT:
Port is used in the outbound process to determine the name of the EDI subsystem program, the directory path where the IDOC file will be created at the operating system level, the IDOC file names and the RFC destinations.

RFC Destination:
Used to define the characteristics of communication links to a remote system on which a functions needs to be executed.

Partner Profile:
Partner profile specified the various components used in an outbound process (Partner number, IDOC type, message type, Port, Process code), the mode in which it communicates with the subsystem (batch or immediate) and the person to be notified in case of errors.

Message Control
Used in pricing, account determination, material determination, and output determination. The message control component enables you to encapsulate business rules with out having to write ABAP programs.

How to Create an IDOCs


Transaction code: WE 30
Steps of Defining Segment
Creating Segment : Tcode - WE31
Creating Message Type : Tcode - we81
Assigning Message type to Idoc type: Tcode - we82
Process
The two processes for IDoc are Outbound Process and Inbound Process.
Outbound Process
When the data is sent out from the system, the process is called Outbound Process and the IDoc is known as Outbound IDoc.
Inbound Process
When the data is coming in, the process is called Inbound Process and the IDoc is known as Inbound IDoc.

Outbound Process (Sending System) Steps :

1) Goto Tcode SALE:
 Creating the logical system
Click on Sending and Receiving Systems à Select Logical Systems--Here Define the Logical Systems à Click on Execute Button
Go for New Entries
1)  System Name : LOG1:Description: Sending System
2)  System Name : LOG2:Description: Receiving System
Press Enter & Save it will ask for Request if you want new request create new request or press continue for transferring the objects.
Assigning Client to the Logical System:
Select Assign Client to Logical Systems -
Client                   : Sending System
Logical System    : LOG1
and also
Client   : Receiving System
Logical System    : LOG2
Save this Data.


How to creare RFC Creation for IDOC

 Goto Tcode SM59 and  Select R/3 Connects
Click on create Button
RFC Destination Name should be same as partner's logical system name and case sensitive to create the ports automatically while generating the partner profiles
Give the information for required fields:
RFC Destination    : LOG2
Connection type    : 3
Target Host            : sappdc.hcl.com
System No              : 01
Client                      : 220
User                        : Login user name
Password                :
Save this & Test it and Remote Login

Step 3) Goto Tcode BD64: 
Click on the change button>Click on the create model view
Short Text: model view
Technical Name: LMOD
Save this & press ok
Select just created model view
Name: "LMOD"
Goto add message type
Model Name  : LMOD
Sender           : LOG1
Receiver         : LOG2
Message type: ZMESS
Save and press Enter.
4) Goto Tcode BD82:
Give Model View   : LMOD
Partner system     : LOG2
Execute this by pressing F8
It will gives you sending system port No:  A00000000089 .
5) Goto Tcode BD64:
Select the model view
Goto >Edit >model view > Distribute
Press ok and Press Enter.
Run your Zprogram
REPORT  ZALE                             .
DATA: Begin of imara occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
end of imara.
DATA: wamas_con LIKE edidc,
ittble_data like   edidd 
ittbel1_con like  edidc 
PARAMETERS: e_matnr LIKE mara-matnr,
e_msgtyp LIKE edidc-mestyp,
e_rcvprn LIKE edidc-rcvprn.

SELECT matnr mtart FROM mara INTO TABLE imara WHERE
matnr = e_matnr.

Master idoc control record
wamas_con-rcvprt = 'LS'.
wamas_con-rcvprn = e_rcvprn.
wamas_con-idoctp = 'ZIDOC'.
wamas_con-mestyp = e_msgtyp.

 master idoc data records
LOOP AT imara.
imas_data-segnam = 'ZSEG'.
move imara to imas_data-sdata .

APPEND ittble_data.
ENDLOOP.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = wamas_con
TABLES
communication_idoc_control = ittble1_con
master_idoc_data = imas_data
COMMIT WORK.

How to check  Transfer of IDOCs 

Tcode - we05
ALE/IDOC Status Codes (outbound):
01=  IDoc Added
30 = IDoc ready for dispatch
29 =Error in ALE service Layer
12 =Dispatch ok
 03 = Data passed to port ok.


Inbound Process (Receiving System) Steps:


Do the same step as you did in sending system
Creating IDoc
Defining the Segment
Creating Message Type
Assigning the Message Type
Defining the Logical System
 Assigning the Logical System
Creating the Distribution Model

1) Goto Tcode - we57:

Assign function module to IDoc type
Module: Function module
Basic type:  
Message type:

Direction: 2 (inbound)
2) Creating Inbound process code - we42
3) Verifying Idoc List Tcode - we05
4) ALE/IDOC Status Codes (Inbound):
50 = IDoc Added
51= Application Document not posted
64 =IDoc ready to be transferred to application
62 =IDoc passed to application
53 = Application Document posted

From this lesson ,we have learnt what is an idoc? and its definition and how to create an idoc and how to check it and how to create program for an idoc?.

Read also
IDOC Status Codes
ALE IDOC Program to send an IDOC
ALE/IDOCs Interview Questions

Comments

Popular posts from this blog

BADI Interview Questions in SAP ABAP

Sample SAP ABAP Programming Examples for Practice

Module Pool Programming Interview Questions and Answers in SAP ABAP

Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP ABAP Interview Questions and Answers for 10 Years Experienced