Vous êtes sur la page 1sur 15

c  


  
  
  
This article will help you understand the basics of ALE and IDocs via a simple do-it-yourself example. We
will create a custom IDoc in one SAP system and then post some business data through it to another SAP system.
Business data will be picked up from custom data dictionary tables.
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 or Intermediate Documents. 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.
Now, let us understand the ALE Configuration by means of an example scenario below:

  
Data from custom tables (created in customer namespace)
is to be formatted into an IDoc and sent from one SAP R/3
system to another using ALE service. We need to have two
instances of SAP R/3 systems or we can simulate this on
two clients of the same SAP R/3 system.

Create three tables as shown below.

       


   
All the objects created should be present on both source as well as target system(s).
'. Create segments ± Transaction WE3'

R Create a segment ZRZSEG'


R Add all fields of table ZCUSTOMERS to it
R Save the segment
R Release it using the menu path Edit -> Set Release
R Similarly create two more segments given below
R Seg. ZRZSEG2 ± to hold all fields of table ZSOHEADERS
R Seg. ZRZSEG3 ± to hold all fields of table ZSOITEMS
2. Create Basic IDoc type ± Transaction WE30

R Create a Basic type ZRZORDER


R Add the created segments in the hierarchy shown
R Maintain attributes for each of the segments
R Save the object and go back
R Release the object using the menu path Edit -> Set Release
3. Create/Assign Message type ± Transactions WE8'/WE82

R Go to WE8'
R Create a new Message type ZRZSO_MT
R Save the object
R Go to WE82 and create new entry
R Assign the message type ZRZSO_MT to the basic type ZRZORDER
R Also specify the Release Version
R Save the object
Thus we have defined the IDoc structure which will hold the data to be transferred. In the next partof the article we
will understand the outbound settings, i.e. the settings to be done in the source system.
c   
  
  
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.
 
 
Define Logical Systems and Assign
Client to Logical System ± Transaction
SALE

R Go to Define Logical System


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

R Create a new RFC destination for R/3 type connection


R Specify the target host on Technical settings tab
R Provide the Logon credentials on the Logon/Security tab
R Save the settings
R To verify the settings, Click on Test connection or Remote logon
Define Ports ± Transaction WE2'

R We need to define a tRFC port for the partner system


R Click on Transactional RFC node
R Create a new port
R Provide a description
R Specify the name of the target RFC destination
R Save the object
Maintain Distribution Model ± Transaction BD64
R Click on Change
R Create a new model view
R Provide a Short text and Technical name to the model view
R Add message type
R Specify sender and receiver systems
R Also, specify the message type that we created previously
R Save the Distribution model
Generate/Create Partner Profile ± Transactions BD82/WE20

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

R Select the Model View


R Go to menu path Edit -> Model View -> Distribute
R Result log will be displayed on the next screen
 
      
Create an executable program ZRZ_ORDER_IDOC in SE38. Below, I have described
the program logic:

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

X X
X  
 
 X
X X
X X

   
 
 

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X     X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X !
X!"#!
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

$%& '    ()
  ) $  (!)
   (!


$$'
&
 &*    (!

  +&*    + (  ) 

  ,&*    , ($& ) $  

  -&*    -($&  "! 


$$'
  &*     ./)) $ &0 
$$'
 ) $ &*   ) $  ./)) $ &0 
$$'
  &*     ./)) $ &0 
$$'
 &*    ./)) $ &0 ( 
$$'
 
 &*    ./)) $ &0 
("" 


 0$0'

  +&*    0$1$& 2   +2 

  ,&*    0$1$& 2   ,2 

  -&*    0$1$& 2   -2

 0$0'
 &*    1$& 2   2



XXX!"
 &   0'
*00    *00 %&$ 3 

1% &0   ) $ 1% &0
$$  '
 3&*    3 $&2  
2 
(45

1&*   1 $&2&2 
(5"6

& 3&*   10 $&237.+2 

1 &*   1  $&2$......,,82 

0 0&*   0 0 $&2& 0 2 

0 &*   0  $&2&2
( ""5

XXX$  &  0
$  &  0
   0 $
$$
   
   0 $
 0 &
   
   0
 



XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

X X
X 4


X X
  0 $
$$
   
   )
  
   )
 ) $ 
   )
  
  $$0
$$
   
0  (4





X X
X 9
:
X X
  )
  
 & X
    
0 $%& 
  
/)  *000
*00
3%0 .
 $  -7;<..=/)202
 0 
0  (9
:



X X
X 9
:9
X X
  )
 ) $ 
 & X
   ) $ 
0 $%& 
 ) $ 
/)  1% &00
1% &0
$0 *000
*00
3%0 .
 $ -7;<..=/)20!2
 0 
0  (9
:9



X X
X 9
:"
X X
  )
  
0 
 ) $ >?0$&
 & X
    
0 $%& 
  
 $&& 0 0
 ) $ 
/)  1% &0@
 ) $ 1% &0
3%0 .
 $ -7;<..=/)20!"2
 0 
 0 
0  (9
:"



X X
X 4
!

X X
  0 $
 0 &
   

&
 1 @
1 ("6

&
  3@
 3(45

&
  @
 (%" 5

&
 1@
1(5"6

&
 10@
& 3(#"6


&
 0 @
0 (5

&
 0 0@
0 0(0#
0  (4
!




X X
X 
"
X X
  0
 
$&&0 02$ 
 
% 2
 A 0
$ 
 
 0 &@
&
 
$%& 
 0$ 0
 
 0 &@
 
 
$ 
 
$$@
 
 A  0
  
0
 
 0 &@+
  
/0
 
$@,
  
0
 
$$@-
 0 0
& $&
3 
0*0 /0@B
 ) @C
3%DE.
 $  3 3 330% 30 
/)31+31,31-31B
 & 
 / *
& $
 
 
/ 'F2 2 
 
  0
 0 & 
 0 
0  (
"



X X
X 4


X X
 $$0
$$
   
 $$'/
0 A+&* 3$%A 
/
0 A,&* 3$%A
 
  %3*00
 
 ) $ %3*001% &0
 
  %31% &0 0

& $
  

  +*00@
  *00

  +0$ +@
  0$ +

  + .+@
   .+

  +&$0 +@
  &$0 +

  0$@
  +

  $$@
  +
$ 0 
 
& $
 

& $/
0 A+
 $ $%& 
 ) $ /)* 3*00@
  *00%0$3
 $)

3%@.
/
0 A+@3$%A
& $
 ) $  /
0 A+

 ) $ *000 
  *00
 A
 0 

  ,1% &0@
 ) $ 1% &0

  ,*00@
 ) $ *00

  0$@
  ,

  $$@
  ,
$ 0 
 
& $
 

& $/
0 A,
 $ $%& 
  /)* 31% &0@
 ) $ 1% &0%0$3
 $)
3%@.
/
0 A,@3$%A
& $
   3$%A

  1% &00 
 ) $ 1% &0
 A
 0 

  -1% &0@
  1% &0

  - 0@
   0

  -$0@
  $0

  -0 /@
  0 /

  -  0@
    0

  0$@
  -

  $$@
  -
$ 0 
 
& $
 
 0 & 
 0 
 0 & 
 0 
 0 & 
0  (4



Thus we have completed sender side configuration required for ALE. In the next part we
will seehow to configure the receiving system to be able to receive and post the inbound
IDoc.
c   
  
  
n 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.
 
   !   
"
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

R Check if the message type is ZRZORDER. Otherwise raise


WRONG_FUNCTION_CALLED exception
R Loop at EDIDD table
R Append data from the segments to appropriate internal tables
R For example: append data from ZRZSEG' segment to the internal table of
type ZCUSTOMERS
R Update the DDic tables from internal tables
R Depending on the result of the update, fill the IDoc status record (type
BDIDOCSTAT) and append it to the corresponding table.
R Status 53 => Success
R Status 5' => Error
You can download the sample ABAP code for the above function module here.

0 0
 
0
 

X(
X(X(&!"'
X( 0
X(1$& <0
 ) =&* % /$
$0 ) 
X(1$& <$
  0=&* % /$
$$
 
X( A 0
X(1$& </ *& /
 &=&* % /
$$ &
X(1$& <$&$ 0
1$$%& =&* % /
$$$&
1$
X(1$& <0
 $
$*=&* % /$
$ $ $*
X(1$& <$&&
$0$ 0
0 =&* % /$
$$&&$0
X($%& 
X( 
 0&   
X( 
$$   
X( 
$ %  $
X( 0
1$$%&  % / 1$
X( $& $ 0
0  % 
 
X( A  0
X(/ 0
0 0
$&& 
X(

X!"!""4$& 
0& %  0/
$%& '    ()
  ) $  (!)
   (!

XXX 
 $$'/
  +&*    + 
/
  ,&*    , 
/
  -&*    -

 $$'
  &*     ./)) $ &0 
 $$'
 ) $ &*   ) $  ./)) $ &0 
 $$'
  &*     ./)) $ &0 



XXXXXXXXXXXXXXXXXX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$$@2C-2
 
$3@22
 
$ @232
 
$0 @2..B2
 
$1+@
 ) $ 1% &0
$ 0  
$
& $ 
$
 & 
 
$ 0@ 
 0& 0
 
$$@2C+2
 
$3@2 2
 
$ @232
 
$0 @2..C2
 
$1+@
 ) $ 1% &0
$ 0  
$
& $ 
$
/ *& /
 &@
/
 &
 
 0
1$$%& /
$$@2 
2
 0
1$$%&  
0% @ 
 0& 0
$ 0  0
1$$%& 
& $ 0
1$$%& 
 0 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X$&  X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X & X
X :"
X 0  & 
X5#0 .
X0 0 :"1$& 
:"
X & 
 $     
  
X 0 
3% H.
 
$ 0@ 
 0& 0
 
$$@2C-2
 
$3@22
 
$ @232
 
$0 @2..B2
 
$1+@
  1% &0
$ 0  
$
& $ 
$
 & 
 
$ 0@ 
 0& 0
 
$$@2C+2
 
$3@2 2
 
$ @232
 
$0 @2..C2
 
$1+@
  1% &0
$ 0  
$
& $ 
$
/ *& /
 &@
/
 &
 
 0
1$$%& /
$$@2 
2
 0
1$$%&  
0% @ 
 0& 0
$ 0  0
1$$%& 
& $ 0
1$$%& 
 0 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 0 & 

0 0 0

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

  # 
 
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.

Thus to summarize we have learned how to:

R Create a custom IDoc


R Write an Outbound IDoc Generation Program
R Write Inbound Function Module to post Inbound IDoc
R Configure and test ALE scenario to transmit data between systems distributed
across the network.

Vous aimerez peut-être aussi