What is IDOC and the IDOC procedure?

Source: Internet
Author: User

Create IDOC:
Step 1: we31 create fields included in the IDOC.
Step 2: we30 create an IDOC and assign the segment to the IDOC
Step 3: Create information types in we81
Step 4: we82 maps the IDOC type to the information type.
Step 5: we57 assign message & IDOC type to a function module for Data Process
Step 6: sm59 define a RFC connection for IDOC Transfer
Step 7: we21 define a port (assign a RFC destination which created in sm59)
Step 8: we41/42 creat Process Code
Step 9: we20 define a partner profiles (also creat a outbound parameters with port, or inbound parameters with Process Code)
Manage IDOC:
We02: IDOC is displayed. You can search for IDOC based on the time and IDOC type, and check the success and error information.
We46 IDOC Management (Out/in)
We60 IDOC type document (you can view the IDOC structure and description of each field.
We19 performs IDOC Processing Based on the IDOC number. You can modify the IDOC value to perform the resend action. The processing is divided into introvert and extrovert.
Message Configuration:
We20 configure the partner message and IDOC type
We21 configuration partner.

Official introduction:

 

What is a IDOC?

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 processing ing systems.
-Idocs are independent of the direction of data exchange.
 

An IDOC type is sap's format for data being moved between applications. essentially, sap has defined what a sales order, financial statement, invoice, etc will look like electronically. this includes des how fields are grouped together (segments), the order and hierarchy of these groupings, and the format of each individual field.

If you're familiar with EDI at all, then an IDOC will look very familiar to you. nearly everything you're used to is there: From segment name to allowable codes to min/MAX occurs.

It is important to note that an IDOC type is really just a structure defined on the system and given a name (I. E ., orders04 ). an actual IDOC, however, consists of data, which fits within the defined structure of the IDOC type. this IDOC is identified by a number rather than by a type.

Creation of 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 & processing ing 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: logging ing 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: using ing System
Logical System: log2

Save this data.
 

Step 2) for RFC creation:
Goto tcode sm59 and select R/3 connects
Click on Create button
RFC destination name shoshould 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.wipro.com
System No: 00
Client: 210
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: zazharmess
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 (like)
 

5) goto tcode bd64:
Select the Model View
Goto> Edit> Model View> distribute
Press OK & press Enter.
 

Run your zprogram
Report zidoc1.
Data: Begin of imara occurs 0,
Matnr like Mara-matnr,
Mtart like Mara-mtart,
End of imara.
Data: wamas_con like edidc,
Imas_data like edidd occurs 0 with header line,
Icom_con like edidc occurs 0 with header line.
Parameters: e_matnr like Mara-matnr,
E_msgtyp like edidc-mestyp,
E_rcvprn like edidc-rcvprn.
* Retrive app. Data from DB
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 = 'zazharidoc '.
Wamas_con-mestyp = e_msgtyp.
* Master IDOC data records
Loop at imara.
Imas_data-segnam = 'zazharseg '.
Move Imara to imas_data-sdata.
Append imas_data.
Endloop.
Call function 'master _ idoc_distribute'
Exporting
Master_idoc_control = wamas_con
Tables
Communication_idoc_control = icom_con
Master_idoc_data = imas_data
Commit work.
 

6) Verifying 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 (grouping 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

---------------------- Instance ------------------------------------------------ outbound IDOC-

 

 

In short, IDOC is an integration tool for an SAP system similar to XML and other systems. If i04 and i02 are SAP systems of two different subsidiaries in the same group, i04 needs to send the procurement order information to i02 in a timely manner. The following describes how to set IDOC. To avoid confusion, my names are special. 1. Set IDOC type. (1) we31 to create a segment, similar to creating XML nodes and node attributes. Enter ypohead and click Create. On the next screen, enter fields such as ebeln, bukrs, and bedat and their corresponding data elements. Then create ypoitem and enter ebeln, ebelp, matnr, menge, Meins, and other fields and their corresponding data element. After saving and using SE12, you will find that the system automatically adds the ypohead and ypoitem structures. Each field is of the char type and the length is the export Leng in we31. (2) we30: Create an IDOC type to define the logical relationship between nodes. First enter ypoidoc, then click Create, and then click Create new. In the main interface, click the create button to add ypohead and set mandatory seg to check, min = 1, max = 1, which means that each IDOC contains only one purchase order. Then add ypoitem under ypohead, and check the same mandatory seg, min = 1, max = 99999. 2. Create message type. (1) we81, create message type. switch to the edit status, click New entries, and enter YPO. (2) we82, which is associated with message type and IDOC type. 3. Create the port to i02. first, make sure that there is an R/3 connection (sm59) to i02 in the system. If not, create an i02001 instance first. Then we21 creates the port, type: transactional RFC, named i02port, and RFC destination, then fill in i02001. 4. Sale: Create a logical system. Sale, sending and processing systems, logical systems, and define logical systems. Add a new logical system named i02ls, which serves as the next partner. Under define logical systems, there is an assign client to logical system. Here we can define a logical system for this system (i04) as the sender ID when sending IDOC, my definition of client 001 is i04ls. 5. we20: define our partner profile. under the partner type is logical system, create a partner whose patner no is i02ls, and set the type to LS. For the following permitted agent, enter us (User). The agent is your user name or basis user name. Click the plus sign below outbound to create an outbound parameter. Message type is YPO, receiver port is i02port, output mode is transfer IDOC immed., basic type is ypoidoc, and save it. 6. I have set so many settings for sending IDOC via programming. It's so tired that I can write it. Program Are you very happy? The idea of the program is to add each IDOC node one by one in the form of strings, and the order of adding strings naturally reflects the logical relationship between IDOC nodes. Code Data: ls_pohead type ypohead,
Ls_poitem type ypoitem,
Ls_edidc type edidc,
Lt_edidc type table of edidc,
Lt_edidd type table of edidd with header line. Clear ls_edidc. * The system can associate with we20 settings based on the following four lines:
Ls_edidc-mestyp = 'ypo'. "Message Type
Ls_edidc-idoctp = 'yidoc'. "IDOC Typels_edidc-rcvprn = 'i02ls'." partner number of recipient
Ls_edidc-rcvprt = 'LS'. "partner type of Cycler * Add IDOC node clear lt_edidd.
Lt_edidd-segnam = 'ypohead'. "node name
Lt_edidd-dtint2 = 0.
Clear ls_pohead.
Ls_pohead-ebeln = '000000 '.
Ls_pohead-bukrs = '000000 '.
Ls_pohead-bedat = '000000 '.
Lt_edidd-sdata = ls_pohead. "node content
Append lt_edidd. Clear lt_edidd.
Lt_edidd-segnam = 'ypoitem '.
Lt_edidd-dtint2 = 0.
Clear ls_poitem.
Ls_poitem-ebeln = '000000 '.
Ls_poitem-ebelp = '000000 '.
Ls_poitem-matnr = '000000 '.
Ls_poitem-menge = '3 '.
Ls_poitem-meins = 'st '.
Lt_edidd-sdata = ls_poitem.
Append lt_edidd. Clear lt_edidd.
Lt_edidd-segnam = 'ypoitem '.
Lt_edidd-dtint2 = 0.
Clear ls_poitem.
Ls_poitem-ebeln = '000000 '.
Ls_poitem-ebelp = '000000 '.
Ls_poitem-matnr = '000000 '.
Ls_poitem-menge = '5 '.
Ls_poitem-meins = 'M '.
Lt_edidd-sdata = ls_poitem.
Append lt_edidd. Call function 'master _ idoc_distribute'
Exporting
Master_idoc_control = ls_edidc "Export
Tables
Communication_idoc_control = lt_edidc "Import
Master_idoc_data = lt_edidd "Export
Exceptions
Error_in_idoc_control = 1
Error_writing_idoc_status = 2
Error_in_idoc_data = 3
Sending_logical_system_unknown = 4
Others = 5.
If sy-subrc <> 0.
Message ID sy-msgid type sy-msgty number sy-msgno
With sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Else.
Commit work.
Write: 'idoc sent :'.
Loop at lt_edidc into ls_edidc.
New-line.
Write: 'idoc number is ', ls_edidc-docnum,
'; Cycler partner is', ls_edidc-rcvprn,
'; Sender partner', ls_edidc-sndprn.
Endloop.
Endif. 7. View IDOC. we05 to view the IDOC we just sent. bd87 can also process IDOC.

--------------------------------------- Instance ---------------------------------- inbound IDOC

The previous article will continue here Article For example, i02 processes the received procurement order information. 1. Create the IDOC type and message type. They are exactly the same as the previous two steps in outbound IDOC. 2. Create a function: y_idoc_po_process. After IDOC is set, sap can automatically call this funtion module to process IDOC. Therefore, the interfaces of this function are standard. Many Inbound functions can be found in the tcode: bd51 described in the following steps, such as idoc_input_bbp_iv. You can refer to create our interface. Next, we can write our code and create corresponding sales orders based on the IDOC content. To simplify the process, we only store it in the database table. Create two tables y02_pohead and y02_poitem first. For the fields, see ypohead and ypoitem in we31. Then write the following code: Data: lv_subrc like sy-subrc,
Ls_chead type ypohead,
Ls_citem type ypoitem,
Ls_pohead type y02_pohead,
Lt_poitem type table of y02_poitem with header line. Clear idoc_contrl.
Read Table idoc_contrl Index 1.
If idoc_contrl-mestyp <> 'ypo '.
Raise wrong_function_called.
Endif. Loop at idoc_contrl.
Clear: ls_pohead, lt_poitem [].
Loop at idoc_data where docnum = idoc_contrl-docnum.
Case idoc_data-segnam.
When 'ypohead '.
Clear: ls_chead, ls_pohead.
Ls_chead = idoc_data-sdata.
Move-corresponding ls_chead to ls_pohead.
When 'ypoitem '.
Clear: ls_citem, lt_poitem.
Ls_citem = idoc_data-sdata.
Move-corresponding ls_citem to lt_poitem.
Append lt_poitem.
When others.
Endcase.
Endloop. lv_subrc = 0.
Insert y02_pohead from ls_pohead.
If sy-subrc = 0.
Insert y02_poitem from Table lt_poitem.
Lv_subrc = sy-subrc.
Else. "the order number already exists.
Lv_subrc = sy-subrc.
Endif. If lv_subrc = 0.
Commit work.
Clear idoc_status.
Idoc_status-docnum = idoc_contrl-docnum.
Idoc_status-status = '53'. "IDOC processed successfully
Append idoc_status.
Else.
Rollback work.
Clear idoc_status.
Idoc_status-docnum = idoc_contrl-docnum.
Idoc_status-status = '51'. "IDOC failed
Idoc_status-msgty = 'E'. "error message
Idoc_status-msgid = 'ymsg '.
Idoc_status-msgno = '001 '.
Append idoc_status.
Endif.
Endloop. 3. register our function module in bd51. In the editing status, click New entries and enter the function name y_idoc_po_process and input type = 1. 4. In we57, associate the function module with IDOC type/Message Type and click New entries. The function module inputs y_idoc_po_process and the type under it is F; the basic type under IDOC type is ypoidoc; enter YPO for Message Type and 2 for direction (inbound ). 5, we42, create inbound Process Code. Note that this step must be completed after bd51 and we57; otherwise, an error message will appear. Create a new entry, enter ypc_po in Process Code, select processing with ale service under option ale, and select function module under processing type. After saving, in the subsequent window, enter inbound module as y_idoc_po_process. 6. we20: maintain partner profiles. First, make sure that the logical system corresponding to the receiver has been maintained in sale, assuming the name is i04ls. (We05 check your inbound IDOC and you can see the partner name. This is what we need .) This step is similar to we20 in the previous article. The difference is that the inbound parameters from i04ls is maintained here. Enter YPO in message type, ypc_po in process type, and select "trigger immediately. 7. Now, our settings are complete. The system will immediately process the received IDOC from i04. At the same time, for those who have done exercises in the previous article, should there be several IDOC errors in the system? You can use bd87 to select the node YPO on the main interface and click "process" to process the node at a time. Before processing, enable y_idoc_po_process in se37 and set several breakpoints for debugging. Supplement: (1) if the status code is 56, it should be that we20 has not been set; (2) because the above Code controls that the same purchase order number cannot be inserted, so only one inbound IDOC will be processed successfully (status code 53), and the rest will fail (status code 51 ). You only need to assign different purchase order numbers to the newly sent IDOC. (3) the status code of outbound is 0-50, and 03 indicates OK; the status code of inbound is 50-, and 53 indicates OK.

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.