Introduction To EDI and ALE:: Advantages
Introduction To EDI and ALE:: Advantages
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.
Advantages:
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.
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.
On both sides:
In Source system:
Creating FM SE37
Standard IDOC:
MASTER Data is the data that exists in the organization like employee details, material master, customer
master, vendor master etc.
Path: ALE--> Basic Settings Logical Systems Assign client to Logical System
Step 3:Create RFC Destination Tcode: SM59
In partner profile we specify the names of the partners which are allowed to exchange IDocs .
Double Click on the Message type MATMAS the following opens.
Enter the details for Receiving port, Pack size and Basic type.
Step 6: Create Customer Distribution model Tcode: BD64
Click on the Create button and enter the short text, Technical name etc as shown below
Now select the created model view and click on Add message type button .A pop up box appears, enter
Sending system, receiving system and message type.
It leads to the next transaction where in the selection screen you have to provide Model view name,
Partner System logical system and execute.
Then, you will be intimated about the partners, port creation, and outbound parameters creation.
Transaction: BD82
Provide Model view and logical system of Partner system to this system (our Outbound system)
Execute, again you will be intimated about the creation of inbound parameters.
NOTE:
You cannot maintain a message type between the same sender and receiver in more than one customer
distribution model.
Only the owner is authorized to modify the model.
Enter the material created or changed, message type and the destination system as follow and execute.
For the partner add the message type .here the message type is MATMAS
Double click on the message type and enter the processing code (MATM) and select Trigger
Immediately radio button, save.
Get the material T.code BD11.
Enter the material created or changed, and the Message as shown below.
Note (The following steps are to be maintained in both the sending and receiving systems)
Check the box so that change pointers get activated and keep track the changes to
Step 2: Activate change pointers for the message type T.code BD50
Create or change a material and check for the Idoc creation in the T.code WE09.
Client 900.
Client 800.
To transfer the data between two clients the table structures and their data types should be match.
In this example, Client 900 is Source system, and Client 800 is destination system.
In Client 900 I have created a customized table and inserted some records.
1.Standard IDOC:
Custom Idoc:
Go to TCODE SALE.
IMG path IDoc Interface / Application Link Enabling (ALE) -> Basic Settings -> Logical
Systems -> Define Logical System
Now you will come back to the IMG path screen. Click on Assign Logical System to client.
IMG Path IDoc Interface / Application Link Enabling (ALE) ->Communication -> Create RFC
Connections
Click on Create button.
Depends upon your settings the destination client will open. If you check the Current user option
under Logon/ Security tab, then it will show the screen directly without asking the user name and
password details.
Creating RFC ports:
Go to TCODE WE21
Select the Transactional RFC in left side tree and click on Create button
In dialog box you can select either Generate port name or own port name. If you select Generate
Port name system will generate automatically. Here I selected Own port name. Click on
continue.
Specify the description and RFC destination name.
Click on Save.
Repeat the same above process in other client. By using opposite client instead of 900 specify
800.
Go to TCODE SE11.
Go to TCODE WE31.
Click on SAVE button, then it will show dialog box with user name, press continue.
Specify your package name and click on save.
Go to TCODE WE30
In dialog box specify the segment name which you created and check mandatory check box.
Click on SAVE and BACK button.
Go to TCODE WE81.
Go to TCODE WE82
Click on Back.
Note:
Go to TCODE BD64
Specify description of model view and technical name in dialog box and press continue.
Select your model view and click on Edit menu -> Add Message type
In dialog box specify the sender, receiver, message type and click on continue.
Now your Model View looks like
In displayed screen select the partner system in left side tree under Partner Type LS.
Write a Report Program in SE38 to create IDOC control records and transfer it to destination
partner system.
The following is the program to generate the IDOC control records and process it.
*&---------------------------------------------------------------------*
*&Report ZSHAN_IDOC_STUD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSHAN_IDOC_STUD.
TABLES: ZSTUDENTS.
DATA : S_CTRL_REC LIKE EDIDC, "Idoc Control Record
S_ZSHSTUSEG LIKE ZSHSTUSEG. "CUSTOMER Header Data
DATA : T_ZSTUDENTS LIKE ZSTUDENTS OCCURS 0 WITH HEADER LINE.
DATA : T_EDIDD LIKE EDIDD OCCURS 0 WITH HEADER LINE. "Data Records
DATA : T_COMM_IDOC LIKE EDIDC OCCURS 0 WITH HEADER LINE. "Generated
Communication IDOc
CONSTANTS :C_ZSHSTUSEG LIKE EDIDD-SEGNAM VALUE 'ZSHSTUSEG'.
CONSTANTS: C_IDOCTP LIKE EDIDC-IDOCTP VALUE 'ZSHSTUDIDOCS'.
*** Selection Screen
SELECT-OPTIONS : S_STUID FOR ZSTUDENTS-ZSTUID OBLIGATORY.
PARAMETERS : C_MESTYP LIKE EDIDC-MESTYP DEFAULT 'ZSHSTUDMT', "Message Type
C_RCVPRT LIKE EDIDC-RCVPRT DEFAULT 'LS', "Partner type
of receiver
C_LOGSYS LIKE EDIDC-RCVPRN DEFAULT 'IT3CLNT800',
C_RCVPOR LIKE EDIDC-RCVPOR DEFAULT 'PORTSH800',
C_SNDPRN LIKE EDIDC-SNDPRN DEFAULT 'IT3CLNT900',
C_SNDPRT LIKE EDIDC-SNDPRT DEFAULT 'LS'. "Destination System
***START-OF-SELECTION
START-OF-SELECTION.
PERFORM GENERATE_DATA_RECORDS.
PERFORM GENERATE_CONTROL_RECORD.
PERFORM SEND_IDOC.
*&---------------------------------------------------------------------*
*&Form GENERATE_DATA_RECORDS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GENERATE_DATA_RECORDS .
SELECT * FROM ZSTUDENTS
INTO TABLE T_ZSTUDENTS
WHERE ZSTUID IN S_STUID.
IF SY-SUBRC NE 0.
MESSAGE E398(00) WITH 'No Students Found'.
ENDIF.
PERFORM ARRANGE_DATA_RECORDS.
ENDFORM." GENERATE_DATA_RECORDS
*&---------------------------------------------------------------------*
*&Form GENERATE_CONTROL_RECORD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GENERATE_CONTROL_RECORD .
S_CTRL_REC-RCVPOR = C_RCVPOR. "Receiver Port
S_CTRL_REC-MESTYP = C_MESTYP. "Message type
S_CTRL_REC-IDOCTP = C_IDOCTP. "Basic IDOC type
S_CTRL_REC-RCVPRT = C_RCVPRT. "Partner type of receiver
S_CTRL_REC-RCVPRN = C_LOGSYS. "Partner number of receiver
S_CTRL_REC-SNDPRT = C_SNDPRT. "Sender Partner type
S_CTRL_REC-SNDPRN = C_SNDPRN. "Sender Partner Number
ENDFORM." GENERATE_CONTROL_RECORD
*&---------------------------------------------------------------------*
*&Form SEND_IDOC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SEND_IDOC .
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = S_CTRL_REC
* OBJ_TYPE = ''
* CHNUM = ''
TABLES
COMMUNICATION_IDOC_CONTROL = T_COMM_IDOC
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
.
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.
LOOP AT T_COMM_IDOC.
WRITE:/ 'IDoc Generated - ', T_COMM_IDOC-DOCNUM.
ENDLOOP.
ENDIF.
ENDFORM. " SEND_IDOC
*&---------------------------------------------------------------------*
*&Form ARRANGE_DATA_RECORDS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ARRANGE_DATA_RECORDS .
DATA: W_INDEX1 LIKE SY-TABIX,
W_INDEX2 LIKE SY-TABIX.
SORT T_ZSTUDENTS BY ZSTUID.
LOOP AT T_ZSTUDENTS.
S_ZSHSTUSEG-ZSTUID = T_ZSTUDENTS-ZSTUID.
S_ZSHSTUSEG-ZSNAME = T_ZSTUDENTS-ZSNAME.
T_EDIDD-SEGNAM = C_ZSHSTUSEG.
T_EDIDD-SDATA = S_ZSHSTUSEG.
APPEND T_EDIDD.
CLEAR T_EDIDD.
ENDLOOP.
ENDFORM." ARRANGE_DATA_RECORDS
Now execute the program, and specify the range of records to transfer
Go to TCODE WE02 to check the generated IDOC control records.
Click on Execute
In Client 800 Steps:
Create a Function Module to update the table from the IDOC segments
Go to SE37
In dialog box specify function group and description, and click on save.
Specify the Import parameters in Import tab
Go to TCODE WE57
Go to TCODE BD51
Specify FM name and Input Types as 2. And Click on Save and Back buttons.
Creating Process Code:
Go to TCODE WE42
In next screen select the FM name and click on SAVE button and Click on BACK button.
It will take to you previous screen. Double Click on Logical Message in left side tree.
Go to TCODE BD64.
To check the partner profile details. Go to TCODE WE20. Select the partner system name.
Transferring the IDOC control records from Client 900 to 800:
Go to TCODE WE02
Check in ZSTUDENTS table in SE11.
Custom Idoc:
1.Business Case
SAP R/3 systems send out data through IDoc (Intermediate Document), which in internally has segments
and fields containing the data. But sometimes, these fields are not sufficient for a specific end-to-end
business scenario as far as data transfer is concerned. So in such scenario, either few fields are to be
added or subtracted, or completely new structure- IDoc needs to be created. This are called as Custom –
IDOC Types. Following blog gives out step-by-step approach for creation of the same.
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.
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.
Run T-code ‘WE81’ to create the logical message types. Go to Edit mode and click New Entry to go to
following screen.
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.
Hence, now our Creation of Custom IDoc is ready to use in ALE scenarios.
Aim: Transfer the data from one system to another using user customized IDOC.
Sender System:
Server: 172.25.8.185
Client: 200
ReceiverSystem:
Server: 172.25.9.198
Client: 800
Data is fetched from Z table on the sender system and inserted it in the Z table of Receiver system using
ALE/IDOC.
Table Creation T – Code SE11.The table contains data that is to be sent to Receiver.
ALE Configuration
T-Code – SALE
Step 1
Step 2
Defining Port
The sender system is connected to the receiver system through this Port.
Since this is a sender we have to define only Outbound Parameters in this case.
T Code WE30
Click on New
This will take you to next screen as follows
Here you have connected the basic type to the segment type.
Enter again and this will take you to screen as follows
This shows the relation between the basic and the segment types.
Next you need to make the entry of the segment in the system table.
Tcode : WE81
This is all about the configuration you need to do on the sender side.
Now on the sender side you also need a program that will fetch the required data, couple it in the
IDOC format and post it.
*&---------------------------------------------------------------------*
*&Report ZSACH_CUST_IDOC *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
report zsach_cust_idoc .
parameters :p_logsys like tbdlst-logsys.
data :gen_segment like edidd-segnam value 'ZSACH'.
data :control_dat like edidc,
gen_data like z1hdr .
tables :zsach1.
data: begin of inttab occurs 0,
lname type z1hdr-lname,
fname type z1hdr-fname,
end of inttab.
data :
int_edidd like edidd occurs 0 with header line,
int_edidc like edidc occurs 0 with header line.
select * from zsach1 into corresponding fields of table inttab.
ifsy-subrc ne 0.
message 'no data' type 'I'.
exit.
endif.
control_dat-mestyp = 'ZSACH'.
control_dat-idoctp = 'ZSACH'.
control_dat-rcvprt = 'LS'.
control_dat-rcvprn = p_logsys.
loop at inttab.
gen_data-lname = inttab-lname.
gen_data-fname = inttab-fname.
* GEN_DATA-SSN = INTTAB-SSN.
* GEN_DATA-DOB = INTTAB-DOB.
int_edidd-segnam = gen_segment.
int_edidd-sdata = gen_data.
appendint_edidd.
endloop.
call function 'MASTER_IDOC_DISTRIBUTE'
exporting
master_idoc_control = control_dat
* OBJ_TYPE = ''
* CHNUM = ''
tables
communication_idoc_control = int_edidc
master_idoc_data = int_edidd
exceptions
error_in_idoc_control =1
error_writing_idoc_status =2
error_in_idoc_data =3
sending_logical_system_unknown =4
others =5
.
ifsy-subrc<> 0.
message id sy-msgid type sy-msgty number sy-msgno.
else.
loop at int_edidc.
write :/ 'IDOC GENERATED',int_edidc-docnum.
endloop.
commit work.
endif.
The ALE configuration is same as we did it on the sender side. Please refer to earlier pages.
T-Code – SALE
Steps
Defining Target System for RFC Calls (Tcode – SM59) (Same as sender)
Defining Port(Same as sender)
Defining Partner Profiles – Here we are accepting the data from Sender system. Hence we need to
configure it as Inbound.
The following steps are repeated, as done on the sender side, on the receiver end
Tcode WE30
Tcode WE31
Tcode WE82
Tcode WE81
Here on the receiver end, we need to specify a process code at the time of defining the partner profile.
Process code is something that has the logic defined about what to be done after receiving the IDOC.
In our case, on receipt of the IDOC, we are updating the Z Table. i.e Inserting the data from the IDOC into
the Z Table.
Creating a Process Code
Tcode – WE42
The logic associated is coded in the Function Module which is specified in the Identification Field above.
TCode – BD51
Once the entry is done here, the function module appears in the drop down list in the previous stage.
Tcode WE57
Sender system
T Code WE02
Tcode: WE02
The IDOC has arrived here
Extended IDOC:
Usually enhancement takes place when the content in IDocs provided by SAP are not sufficient for the
business process. IDoc extension can take place whenever dictionary table has a new structure appended
required by the business process.
In brief IDoc extension takes place when extra fields are required for the business process.
In this scenario say visitor is different from the actual customer who has came to the sales office in behalf
of the customer to obtain the quotation or inquiry etc. Or an authorized agent qualified by the actual
customer to order for items. So a field by name NAMEVI (Visitor) is added to Customer master data. As
there is no provision given by SAP to handle this, we need to extend an IDoc.
The standard message type and IDoc type provided by SAP are DEBMAS and DEBMAS05.
Consider the data in the table below for extending the IDoc. These details can be understood in different
sections in the process of extending it.
Outbound process
Step2: Write a module pool program to update some existing customers to add data for Visitor.
Save
Transaction WE30
Object Name DEBMASEXT
Choose Extension
Observe all the segments to be copied into your IDoc extension from linked basic
type.
Select E1KNA11 and click (create segment) to obtain a popup window
Provide the required values and observe child segment Z1KNA11 to be added to
Transaction: WE31
Transaction: WE82
Click , then
Save.
Transaction: WE30
Now transport
Transaction: SE84.
Click Enhancements
Alternative way
Transaction: SMOD
Path: F4help -> SAP Applications -> Logistics general -> Logistics Basic Data ->
Now search for different extensions like VSV00001. Then see for its components.
Additional Customer Master Segments). This user exit can be used in outbound ALE
helpful for inbound ALE process. This user exit can be used to read the segments
Transaction: CMOD.
From the initial screen of the transaction, select components and click change.
Activate them.
Select user exit EXIT_SAPLVV01_001 for outbound process and double click it. It leads to function builder.
Now, write supporting code for IDoc extension, i.e., populating custom segments in IDoc.
Code in ZXVSVU01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*extended
*&---------------------------------------------------------------------*
*Data declarations
checkmessage_typeeq 'DEBMAS'.
checksegment_nameeq 'E1KNA1M'.
* since customer number is not passed in this user exit, you need to go
loop at idoc_data.
caseidoc_data-segnam.
when 'E1KNA1M'.
moveidoc_data-sdata to kna1m.
when 'E1KNA11'.
moveidoc_data-sdata to kna11.
select single *
into w_kna1
ifsy-subrceq 0.
idoc_cimtype = 'DEBMASEX'.
clear z1kna11.
condense: z1kna11-visitor.
* populate segment name in the data record, copy data contents into it
appendidoc_data.
Step 10:
Define Logical System
Assign client to Logical System
Maintain RFC Destination
Maintain Customer Distribution Model
Generate Partner Profiles
Distribute Customer Distribution Model
INBOUND PROCESS
Step 11: Append the custom structure to the table KNA1 similar to the process done
in outbound process.
Step 12.
Step 13. Execute the transaction to ‘Send Customers’ from Outbound system.
Step 14. Now in the Inbound system, create the project in the similar way as done at
outbound side.
In the user exit EXIT_SAPLVV02_001, find include ‘ZXVSVU02’. Write the code to
supportIDoc extension.
Code in ZXVSVU02
*&---------------------------------------------------------------------*
*& IncludeZXVSVU02 *
*&---------------------------------------------------------------------*
LOOP AT IDOC_data.
caseidoc_data-segnam.
when 'E1KNA1M'.
kna1m = idoc_data-sdata.
when 'E1KNA11'.
kna11 = idoc_data-sdata.
when 'Z1KNA11'.
z1kna11 = idoc_data-sdata.
select single *
from kna1
into fs_kna1
ifsy-subrceq 0.
update kna1
wherekunnr = kna1m-kunnr.
else.
idoc_status-docnum = idoc_control-docnum.
idoc_status-status = '51'.
idoc_status-msgty = 'E'.
idoc_status-msgid = 'ZE'.
idoc_status-msgno = '005'.
idoc_status-msgv1 = kna1m-kunnr.
appendidoc_status.
Transaction: WE57
1. Change Pointers
Change Pointers are log entries to remember all modified records relevant for ALE. Change pointers are
log entries to table BDCP, which are written every time a transaction modifies certain fields.
Below screen shows Activating change pointer for Message Type 'MATMAS'
In above screen if active flag (Check box) is unchecked then Change pointers is deactivated.
B) TCODE: BD66 (Segment Field-Change Document field)
Change Document field should exist in this TCODE align particular Segment type.
If some messages types are no longer to be distributed by change pointers, you can deactivate change
pointers for this message type (by removing active flag in BD50). We can deactivate change pointers for
the message type and reactivate them again in transaction BD50.
Following screen shows how to deactivate change pointers for reduced message types.
Example: I have taken ‘ZMATMAS’. Here the shaded part is shows Deactivate change pointers PUSH
button.
TCODE: BD21
Program: RBDMIDOC
We can create IDOCS from change pointers with the report RBDMIDOC
The report tells how many master and communication IDocs have been created.
TCODE: BD22
Program: RBDCPCLR
Here we can delete obsolete and processed change pointers in specific time and for specific message
type.
Example:
In above screen I have selected obsolete change pointers for MATMAS message type.
Example:
Execute