Вы находитесь на странице: 1из 8

Creation of Custom IDOC Type

1. Business Case
ALE Application Link Enabling is a mechanism by which SAP systems communicate with each other and with non-SAP EDI subsystems. Thus it helps integration of distributed systems. It supports fail-safe delivery which implies that sender system does not have to worry about message not reaching the source due to unavoidable situations. ALE can be used for migration and maintenance of master data as well as for exchanging transactional data. The messages that are exchanged are in the form of IDocs (Intermediate Documents), which in internally has segments and fields containing the data.. IDocs act like a container or envelope for the application data. An IDOC is created as a result of execution of an Outbound ALE. In an Inbound ALE an IDOC serves as an input to create application document. In the SAP system IDocs are stored in the database tables. They can be used for SAP to SAP and SAP to non-SAP process communication as long as the participating processes can understand the syntax and semantics of the data. Complete documentation on IDOC is obtained by using transaction WE60. Every IDoc has exactly one control record along with a number of data records and status records. Control record has the details of sender/receiver and other control information. Data records contain the actual business data to be exchanged while the status records are attached to IDoc throughout the process as the IDoc moves from one step to other.

2. Development of IDOC types 2.1 Creation of Segment Types


Run T-code WE31 to create segment type, which has fields to contain the data and are added to the segment type in the same transaction. The data stored contained into the segment mesh is finally stored in EDISEGMENT table.

Add your custom fields as per business scenario.

To make it available to other transactions, release the segment created.

Go to Edit -> Set Release 2.2 Creation of IDoc type


Run T-code WE30 to create custom IDoc type. Enter the name of custom IDoc you want to create and click on red box for creation.

Now, it takes you to following screen. Here you can add description for your IDoc type. Also you can specify name of existing IDoc for Copy or Successor mode. Now, you can maintain attributes of the custom IDoc, which consists of attaching segment type created above to the IDoc type. Also specifying the details of frequency of these segments getting filled i.e. Maximum and Minimum number. Fill the necessary details and release this IDoc type as well.

2.3 Creation of logical message types

Run T-code WE81 to create the logical message types. Go to Edit mode and click New Entry to go to following screen.

Save the entered data.

2.4 Linking Message type and IDoc type.


Run T-Code WE82. Now we have to link these created IDoc types and Message types. Enter the message type name, Basic IDoc type (ZCUST_IDC) and release type to be linked. In the data transfer through ALE, these message types represent the IDOC structure.

Extension field above will be used as per the Extended IDoc type scenario i.e. in case of addition of few more fields into the existing IDoc type.

3. Sending of an outbound IDoc


In the previous part we created an IDoc structure which can carry our data from source system to target system(s). In this part we will understand how to setup the source system to be able to generate and send an outbound IDoc.

1. Define Logical Systems and Assign Client to Logical System Transaction SALE

Go to Define Logical System (See the figure) Define a new logical system to identify the local system and save it Now, go to Assign Client to Logical System (See the figure) Add a new entry Specify the client, previously created logical system and other attributes Save the entry Define a new logical system to identify the partner system and save it

2. Maintain RFC Destinations Transaction SM59


Create a new RFC destination for R/3 type connection Specify the target host on Technical settings tab Provide the Logon credentials on the Logon/Security tab Save the settings To verify the settings, Click on Test connection or Remote logon

3. Define Ports Transaction WE21


We need to define a RFC port for the partner system Click on Transactional RFC node Create a new port Provide a description Specify the name of the target RFC destination Save the object

4. Maintain Distribution Model Transaction BD64


Click on Change Create a new model view Provide a Short text and Technical name to the model view Add message type Specify sender and receiver systems Also, specify the message type that we created previously Save the Distribution model

5. Generate/Create Partner Profile Transactions BD82/WE20


To generate Partner profiles automatically you may use BD82 or go to BD64 and use the menu path Environment -> Generate partner profiles o Otherwise, you may use transaction WE20 to create a partner profile On selection screen, specify the model view, target system and execute The result log will be displayed on the next screen To verify the partner profile go to WE20 Check the partner profile for the target system

6. Distribute Model View Transaction BD64


Select the Model View Go to menu path Edit -> Model View -> Distribute Result log will be displayed on the next screen

7. Outbound IDoc Generation Program


Create an executable program ZRZ_ORDER_IDOC in SE38. Below, I have described the program logic:

Fetch the data from the DDic tables ZCUSTOMERS, ZSOHEADERS and ZSOITEMS as per the selection criteria Fill the control record structure of type EDIDC o Specify message type, Basic IDoc type, tRFC Port, Partner number and Partner type of the receiver Fill the data records o Define structures like the IDoc segments o Fill the structures with fetched data o Pass the segment name and the above structure to the appropriate fields of EDIDD type structure o Append the EDIDD structure to the EDIDD type internal table Now, call the function module MASTER_IDOC_DISTRIBUTE and pass the IDoc control record structure and data record table Commit work if return code is zero Function module returns a table of type EDIDC to provide the details about generated IDoc Display appropriate log

Thus we have completed sender side configuration required for ALE. In the next part we will see how to configure the receiving system to be able to receive and post the inbound IDoc.

4. Sending of an outbound IDoc


In the previous parts we learned how to create a custom IDoc and set up the source system to send an outbound IDoc. In this part we will learn how to configure the receiving SAP R/3 system to be able to receive and post the inbound IDoc. Inbound IDoc Posting Function Module In the receiving system, create a function module Z_IDOC_INPUT_ZRZSO_MT using SE37. Below, I have described the logic for the same. Add Include MBDCONWF. This include contains predefined ALE constants. Loop at EDIDC table

Check if the message type is ZRZORDER. Otherwise raise WRONG_FUNCTION_CALLED exception Loop at EDIDD table

Append data from the segments to appropriate internal tables For example: append data from ZRZSEG1 segment to the internal table of type ZCUSTOMERS Update the DDic tables from internal tables Depending on the result of the update, fill the IDoc status record (type BDIDOCSTAT) and append it to the corresponding table. o Status 53 => Success o Status 51 => Error

o o

Inbound Settings

Define Logical Systems Transaction SALE (Please refer to Outbound Settings discussed in previous part) Assign Client to Logical System Transaction SALE (Please refer to Outbound Settings discussed in previous part) Maintain RFC Destinations Transaction SM59 (Please refer to Outbound Settings discussed in previous part) Define Ports Transaction WE21 (Please refer to Outbound Settings discussed in previous part) Generate/Create Partner Profile Transactions BD82/WE20 (Please refer to Outbound Settings discussed in previous part) Assign Function Module to Logical message Transaction WE57 o Create a new entry o Specify name of the Function Module as Z_IDOC_INPUT_ZRZSO_MT o Also, specify Type as F, Basic IDoc type as ZRZORDER, Message type as ZRZSO_MT and Direction as 2 (Inbound) o Save the entry Define Input method for Inbound Function Module Transaction BD51 o Create a new entry o Provide Function Module name as Z_IDOC_INPUT_ZRZSO_MT o Specify the Input method as 2 o Save the entry Create a Process Code Transaction WE42 o Create a new Process Code ZPCRZ o Select Processing with ALE Service o Choose Processing type as Processing by function module o Save the entry o On the next screen, select your function module from the list o Save the changes o Now you will be taken to the next screen o Double-click on Logical message o In the Assignment to logical message, specify the message type ZRZSO_MT o Save the changes

Send and receive data On the sender system, execute the IDoc Generation Program. Check the status of IDoc using transaction WE02.

Check the status of the IDoc in the receiver system using transaction WE02. You can also check the contents of DDic tables to make sure that the records have been created in the receiver system.

Rsum des transactions: Se11 to create data element We31 to create segment We30 to create idoc type We05 to view generated idoc

Вам также может понравиться