100% found this document useful (1 vote)
231 views24 pages

ALE Between Two SAP Systems

The document describes the steps to configure ALE (Application Link Enabling) and IDOC (Intermediate Document) to transfer student data from SAP system 800 to SAP system 810. The steps include creating tables, segments, IDOC types, message types, logical systems, RFC destinations, and ports in both the source and target systems. An inbound function module is created in the target system to process the incoming IDOC and update the student table.

Uploaded by

raghava nimmala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
231 views24 pages

ALE Between Two SAP Systems

The document describes the steps to configure ALE (Application Link Enabling) and IDOC (Intermediate Document) to transfer student data from SAP system 800 to SAP system 810. The steps include creating tables, segments, IDOC types, message types, logical systems, RFC destinations, and ports in both the source and target systems. An inbound function module is created in the target system to process the incoming IDOC and update the student table.

Uploaded by

raghava nimmala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

ALE IDOC Development between two SAP

systems
Developing and configuring IDOC using ALE to send and receive data from one SAP
system to another SAP system

A+ A-

As a pert or training, we don`t have many systems to work on multiple systems, we


will develop ALE connection and data transfer between two clients with in the same
system.

In practice versions we have two clients 800 and 810, for practice purpose we will
send data to 810 client from 800 client using ALE IDOCS.

By the end of this lesson you will be able to understand ALE and IDOC
implementation and you will be able to develop a real-time communication network
between two systems to send and receive data using ALE network by using IDOC.

As per practice/training purpose we assume 800 and 810 clients are different
systems (If you don`t have 800 and 810 clients in your system, use any other
clients).

Assume client 800 is source system and client 810 is destination system.

Requirement: All the students data will be created in 800 client and same will be
send to 810 client using IDOCS.
Steps to be done in 800 client

Login to 800 client and do following.

1. Create a table (client dependent).


2. Create segments.
3. Create IDOC type.
4. Create message type.
5. Assign message type to IDOC type.
6. Define logical system.
7. Assign logical system to client.
8. Create RFC destination.
9. Create port.
10. Check partner profiles.
11. Create outbound program.

Steps to be done in 810(Target System) client.

1. Create a table (client dependent).


2. Create segments.
3. Create IDOC type.
4. Create message type.
5. Assign message type to IDOC type.
6. Define logical system.
7. Assign logical system to client.
8. Create inbound function module SE37.
9. Register function module characteristics.
10. Assign function module to message and IDOC type.
11. Create process code WE42.
12. Check partner profiles for inbound.

Step 1: Create a client dependent custom table ZSTUDENTS.

Go to SE11, provide name as ZSTUDENTS and click on create.

Provide delivery class and display maintenance.


Add fields as below.

Click on technical settings.

Provide data class, size category and save.


Step 2: Go to WE31 and create a segment as below.

Go to t-code WE31, provide segment as ZSTUDENT and click on create.

Just click enter if you find any information message and add fields as below.

Save it in a local object.

Step 3: Create IDOC type.


Go to WE30, provide name as ZSTUDENT and click on create.

Provide description and press enter.

Select ZSTUDENT and click on create.


Provide a segment name (which we have created in step2), maximum and minimum
numbers and enter.

Save it in a local object.

Step 4: Create a message type.

Go to t-code WE81 and click on change icon.

Provide message type as ZSTUDENT and description.


Step 5: Assign message type to IDOC type.

Go to t-code WE82, click on change and click on new entries.

Provide message type, IDOC type and release as below.

Save it in a transport request.

Step 6: Define logical system.

This is the most confusing step in ALE configurations, try to understand carefully.

What is logical system?


'Logical system' is used to identify an individual client in a system, for
ALE communication between SAP systems. That's why you see a field for
'logical system' in the client master data in SCC4 (table T000). You use logical
systems in ALE configuration - this should be documented further in the IMG guide,
or SALE transaction

Before creating a logical system please follows below steps.

In a blind way logical system assigned in target system client(in our example 810
client) should be in logical system definition in source client.

Step 1: Go to target system( In our example 810 client).


(Get logical system from t-code SALE ->Basic Settings ->Logical Systems -> assign
logical system to client -> 810 (double click and copy logical system)).
Step 2: Go to SALE.
Expand basic settings -> define logical system.

Check for logical system existence(which we get from 810 client) if it is there, no
need to add, if it is not there add it.

Step 7: Assign logical system to client.


For now skip this.

Create RFC destination .

Go to T-code SM59, select ABAP connections and click on create.

Provide RFC destination, description, hostname and system number.

Click on logon and security tab, provide client, user name, password and save.
Click on connection test to test connection.

Click on remote logon to logon to remote client(you will go to 810 client).


Step 9: Create PORT in WE21 .

Go to t-code WE21, select transactional RFC and click on create.

Select generate port name and enter.


Provide RFC destination, which we created in step 8.

Save.

Step 10: Check partner profiles in WE20.

Go to WE20, expand partner type logical system and search for logical system (Get
logical system from t-code SALE ->Basic Settings ->Logical Systems -> assign
logical system to client -> 810 (double click and copy logical system)).
If logical system is already available in partner profiles in WE20, we don`t need to
create partner profile again instead we will add message type at out bound
parameters level. In my case, logical system is already available in partner profiles
so I will add ZSTUDENT message type to it. To add message type, select logical
system, click on add icon (see below image).

Provide message type, receiver port (which we have created in step9), select
transfer IDOC immediately, basic type and save.
If logical system is not available in partner profile in WE20, select partner type logical
system and click on create.

Provide partner no as T90CLNT810 (Get logical system from t-code SALE ->Basic
Settings ->Logical Systems -> assign logical system to client -> 810 (double click
and copy logical system). Save and add message type at out bound partner level.

Steps to be done in 810 client


Continue 1 - 7 steps as same as 800 client.
Step 8: Create inbound function module.

Every inbound IDOC will have process code, every process code is associated with
a inbound process ex: Function Module or Work Flow Task.

Follow below steps to create inbound function module.

1. Create a function group in SE80.


2. Copy Function module IDOC_INPUT_MATMAS01.
3. Add your own code.

Step 1: Go to SE80, select function group, provide a name ZSTUDENT_IDOC,


enter.
Save and activate function group.

Step 2: Go to SE37, provide function module name as IDOC_INPUT_MATMAS01,


click on copy, provide function module name as function group and enter.

Step 3: Add your own code in function module. Go to Se37, provide name as
ZSAPN_IDOC_INPUT_STUDENT, click on change. Remove all code and add below
code.
FUNCTION ZSAPN_IDOC_INPUT_STUDENT.
*"---------------------------------------------------------------------
-
*"*"Local Interface:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" VALUE(NO_APPLICATION_LOG) LIKE SY-DATAR OPTIONAL
*" VALUE(MASSSAVEINFOS) LIKE MASSSAVINF STRUCTURE MASSSAVINF
*" OPTIONAL
*" VALUE(KZ_TEST) LIKE MDAT1-KZ_TEST DEFAULT SPACE
*" VALUE(ONLY_MAPPING) LIKE MDAT1-KZ_TEST DEFAULT SPACE
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT
*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR
*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
*" TABLES
*" IDOC_CONTRL STRUCTURE EDIDC
*" IDOC_DATA STRUCTURE EDIDD
*" IDOC_STATUS STRUCTURE BDIDOCSTAT
*" RETURN_VARIABLES STRUCTURE BDWFRETVAR
*" SERIALIZATION_INFO STRUCTURE BDI_SER
*" EXCEPTIONS
*" WRONG_FUNCTION_CALLED
*"---------------------------------------------------------------------
-
SORT IDOC_DATA BY DOCNUM.
SORT IDOC_CONTRL BY DOCNUM.
DATA : T_EDIDD TYPE STANDARD TABLE OF EDIDD,
"Data Record
T_EDIDC TYPE STANDARD TABLE OF EDIDC,
"Control Record
T_EDIDS TYPE STANDARD TABLE OF BDIDOCSTAT.
"Status Record
*----------*Global Work Area Declarations *------------------------*
DATA : W_EDIDC LIKE EDIDC,
W_EDIDD TYPE EDIDD,
W_EDIDS TYPE BDIDOCSTAT.
DATA: W_IDOC_DATA TYPE EDIDD.
DATA : L_INDX TYPE SYTABIX.
DATA: IT_STUDENT TYPE TABLE OF ZSTUDENT.
DATA : WA_STUDENT TYPE ZSTUDENT.
DATA : ERROR_MESSAGE TYPE STRING.
DATA : T_STUDENTS TYPE TABLE OF ZSTUDENTS.
DATA : W_STUDENTS TYPE ZSTUDENTS.
DATA : ERROR_FLG TYPE CHAR1.
* Go through all IDocs
LOOP AT IDOC_CONTRL.
CLEAR W_EDIDC.
W_EDIDC = IDOC_CONTRL.
READ TABLE IDOC_DATA INTO W_IDOC_DATA WITH KEY DOCNUM =
IDOC_CONTRL-DOCNUM BINARY SEARCH.
IF SY-SUBRC = 0.
L_INDX = SY-TABIX.
LOOP AT IDOC_DATA FROM L_INDX.
IF IDOC_DATA-DOCNUM = IDOC_CONTRL-DOCNUM.
APPEND IDOC_DATA TO T_EDIDD.
CLEAR IDOC_DATA.
ELSE.
RETURN.
ENDIF.
ENDLOOP.
ELSE.
CONTINUE.
ENDIF.
SORT T_EDIDD.

CLEAR W_EDIDD.
LOOP AT T_EDIDD INTO W_EDIDD.
IF W_EDIDD-SEGNAM = 'ZSTUDENT'.
CLEAR WA_STUDENT.
WA_STUDENT = W_EDIDD-SDATA.
IF WA_STUDENT IS NOT INITIAL.
APPEND WA_STUDENT TO IT_STUDENT.
ENDIF.
CONTINUE.
ENDIF.
ENDLOOP.
IF IT_STUDENT IS NOT INITIAL. "if data is there in segment
LOOP AT IT_STUDENT INTO WA_STUDENT.
MOVE-CORRESPONDING WA_STUDENT TO W_STUDENTS.
MODIFY ZSTUDENTS FROM W_STUDENTS. "update data base table
IF SY-SUBRC <> 0.
ERROR_FLG = 'X'.
ERROR_MESSAGE = 'Error occured in updating ZSTUDENT table'.
ENDIF.
ENDLOOP.
ENDIF.
IF ERROR_FLG = 'X'. "add error status to IDOC
IDOC_STATUS-STATUS = '51'.
IDOC_STATUS-DOCNUM = W_EDIDC-DOCNUM.
IDOC_STATUS-MSGTY = 'E'.
IDOC_STATUS-MSGID = '00'.
IDOC_STATUS-MSGNO = '398'.
IDOC_STATUS-MSGV1 = ERROR_MESSAGE+0(25). "t_return_ecm-message
IDOC_STATUS-MSGV2 = ERROR_MESSAGE+25(25).
IDOC_STATUS-MSGV3 = ERROR_MESSAGE+50(25).
IDOC_STATUS-MSGV4 = ERROR_MESSAGE+75(25).
CLEAR ERROR_MESSAGE.
APPEND IDOC_STATUS TO IDOC_STATUS .
CLEAR IDOC_STATUS .
else. "add success status to IDOC
IDOC_STATUS-STATUS = '53'.
IDOC_STATUS-DOCNUM = W_EDIDC-DOCNUM.
APPEND IDOC_STATUS TO IDOC_STATUS .
CLEAR IDOC_STATUS .
ENDIF.
ENDLOOP.
ENDFUNCTION.
Save and activate.

Step 9: Register inbound function module characteristics.

Go to BD51, click on change and click on new entries.

IMP Note: If you don`t find change icon or if you find a message like 'You are not
allowed to cross client customization' log on to 800 client and do this step.

Add an entry as below.

Save it in a transport request.

Step 10: Assign function module to message type.

Go to WE57, click on change and new entries.

IMP Note: If you don`t find change icon or if you find a message like 'You are not
allowed to cross client customization' log on to 800 client and do this step.
Save it in a transport request.

Step 11: Create process code.

Go to WE42, click on change and click on new entries.

Provide a process code, descriptions.


Click Save, create a transport request. Select function module from drop down and
save it in transport request.

Step 12: Check partner profiles for inbound.


Go to WE20, expand logical system and select logical system(Get logical system
from t-code SALE ->Basic Settings ->Logical Systems -> assign logical system to
client -> 800 (double click and copy logical system)).

Click on add icon under inbound parameters.

Add entries as below.


Save.

Testing the development


Follow the below steps to test the above development.

1. Create entries in ZSTUDENTS table in 800 client.


2. Create outbound program.
3. Execute the program and send students from 800 to 810 clients.

Create entries in 800 client.


Go to SE11, provide name as ZSTUDENTS and click on display.

Go to utilities -> table entries -> create entries.


Similarly add some more entries.

Go to SE38, create a program to send students to 810 client.


Create a program with name ZSAPN_SEND_STUDENTS and add below code.

REPORT ZSEND_STUDENTS.

DATA: ZSTUDENTS TYPE TABLE OF ZSTUDENTS.


DATA : WA_STUDENTS TYPE ZSTUDENTS.

TYPES : BEGIN OF TY_ZSTUDENT. "STRUCTURE FOR SEGMENT DATA


INCLUDE STRUCTURE ZSTUDENT.
TYPES : END OF TY_ZSTUDENT.
DATA : ZSTUDENT TYPE TY_ZSTUDENT.
DATA: BEGIN OF T_EDIDD OCCURS 0.
INCLUDE STRUCTURE EDIDD.
DATA: END OF T_EDIDD.

DATA: BEGIN OF F_EDIDC.


INCLUDE STRUCTURE EDIDC.
DATA: END OF F_EDIDC.

DATA: BEGIN OF T_EDIDC OCCURS 0.


INCLUDE STRUCTURE EDIDC.
DATA: END OF T_EDIDC.
SELECT-OPTIONS: S_STD FOR WA_STUDENTS-STUDENT_ID.

START-OF-SELECTION.
SELECT * FROM ZSTUDENTS INTO TABLE ZSTUDENTS WHERE STUDENT_ID IN
S_STD.
LOOP AT ZSTUDENTS INTO WA_STUDENTS. "send students on eby one
MOVE-CORRESPONDING WA_STUDENTS TO ZSTUDENT.
CLEAR T_EDIDD.
T_EDIDD-SEGNAM = 'ZSTUDENT'. "segment name
T_EDIDD-SDATA = ZSTUDENT. "IDOC data record
APPEND T_EDIDD.
* Fill control record
CLEAR F_EDIDC.
F_EDIDC-MESTYP = 'ZSTUDENT'. "Message type
F_EDIDC-DOCTYP = 'ZSTUDENT'. "IDOC type
F_EDIDC-RCVPRT = 'LS'. "Partner type
F_EDIDC-RCVPRN = 'T90CLNT810'. "Receiver partner

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'


EXPORTING
MASTER_IDOC_CONTROL = F_EDIDC ">>>>>
TABLES
COMMUNICATION_IDOC_CONTROL = T_EDIDC "<<<<<
MASTER_IDOC_DATA = T_EDIDD ">>>>>
EXCEPTIONS
ERROR_IN_IDOC_CONTROL = 1
ERROR_WRITING_IDOC_STATUS = 2
ERROR_IN_IDOC_DATA = 3
SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
OTHERS = 5.

COMMIT WORK.
CLEAR : WA_STUDENTS, ZSTUDENT.
REFRESH : T_EDIDD.
ENDLOOP.
Execute the above program and provide students ids to send.
Now go to WE09 and check status in 800 client.

Go to 810 client and check table ZSTUDENTS for entries(entries should be created).

You might also like