Sei sulla pagina 1di 24

ALE-IDOC Scenario using Custom IDOC

Aim: Transfer the data from one system to another using user customized IDOC. Sender System: Client: 800 Data from Z table: zsach1 is having fields MANDT, NAM!, "NAM ReceiverSystem: Client: 810 Data from Z table: zsach1 Data is fetched from Z table on the sender s#stem and inserted it in the Z table of $eceiver s#stem %sing A !&'D(C) Settings on the Sender End Table Creation T * Code +!11) The table contains data that is to be sent to $eceiver) ALE Configuration T,Code * +A !

Defining Logica System

!"" is our sender #"" is our receiver Assigning C ient to Logica System

!"" is our sender #"" is our receiver Defining Target System for R$C Ca s %Tcode & S'()*

Clic- on $&. Connections and then Create TA/ +te0 1

Ste+ !

+ave and test the connection) Defining ,ort

The sender s#stem is connected to the receiver s#stem thro%gh this 1ort)

Defining ,artner ,rofi es

The 0artner for client 2003+ender4 is the client 800 3$eceiver4 +ince this is a sender 5e have to define onl# (%tbo%nd 1arameters in this case) 6ere #o% can see the Message t#0e is Z message t#0e) 2) Maintaining Distrib%tion Model 3 TCode /D78 4

Create ne5 Distri-ution 'ode

Add Message T#0e

.o/ Distri-ute this 'ode 0ie/

Distrib%te it from !dit Model 9ie5 Distrib%te

Defining the 1 Segment ty+e Tcode & 2E34

Defining the 5asic Ty+e T Code 2E3"

C ic6 on .e/

This /i ta6e you to ne7t screen as fo o/s

8ere you have connected the -asic ty+e to the segment ty+e. !nter again and this 5ill ta-e #o% to screen as follo5s

This sho5s the relation bet5een the basic and the segment t#0es) Ne:t #o% need to ma-e the entr# of the segment in the s#stem table) Tcode : 2E#4

.e7t is the fo o/ing entry /hich is re9uired.

8ere you are s+ecifying the message ty+e and the -asic ty+e and the re ease version. This is a a-out the configuration you need to do on the sender side. .o/ on the sender side you a so need a +rogram that /i fetch the re9uired data: cou+ e it in the IDOC format and +ost it. 8ere is a sma +iece of code that cou d -e usefu . ;<,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,; ;< $e0ort Z+AC6=C>+T='D(C ;< ; ;<,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,; ;< ; ;< ; ;<,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,; re0ort zsach=c%st=idoc ) data : gen=segment li-e edidd,segnam val%e ?Z+AC6?) data : control=dat li-e edidc, gen=data li-e z1hdr ) data :inttab li-e zsach1 occ%rs 0) data: begin of inttab occ%rs 0, lname t#0e z1hdr,lname, fname t#0e z1hdr,fname, end of inttab) data : int=edidd li-e edidd occ%rs 0 5ith header line, int=edidc li-e edidc occ%rs 0 5ith header line) 0arameters : 0=logs#s li-e tbdlst,logs#s)

select ; from zsach1 into corres0onding fields of table inttab) if s#,s%brc ne 0) message ?no data? t#0e ?'?) e:it) endif) control=dat,mest#0 @ ?Z+AC6?) control=dat,idoct0 @ ?Z+AC6?) control=dat,rcv0rt @ ? +?)

control=dat,rcv0rn @ 0=logs#s) loo0 at inttab) gen=data,lname @ inttab,lname) gen=data,fname @ inttab,fname) ; A!N=DATA,++N @ 'NTTA/,++N) ; A!N=DATA,D(/ @ 'NTTA/,D(/) int=edidd,segnam @ gen=segment) int=edidd,sdata @ gen=data) a00end int=edidd) endloo0) call f%nction ?MA+T!$='D(C=D'+T$'/>T!? e:0orting master=idoc=control @ control=dat ; (/B=TC1! @ ?? ; C6N>M @ ?? tables comm%nication=idoc=control @ int=edidc master=idoc=data @ int=edidd e:ce0tions error=in=idoc=control @1 error=5riting=idoc=stat%s @2 error=in=idoc=data @. sending=logical=s#stem=%n-no5n @8 others @D ) if s#,s%brc EF 0) message id s#,msgid t#0e s#,msgt# n%mber s#,msgno) else) loo0 at int=edidc) 5rite :& ?'D(C A!N!$AT!D?,int=edidc,docn%m) endloo0) commit 5or-) endif) .OTE:/e can /rite a-ove +rogram a so as discussed in C ass

Settings on the Receiver side %In-ound idoc* The A ! config%ration is same as 5e did it on the sender side) 1lease refer to earlier 0ages) The receiver s0ecific differences are mentioned belo5) T,Code * +A ! 200 is o%r sender 800 is o%r receiver Ste+s Defining ogical +#stem 3+ame as sender4 Assigning Client to ogical +#stem 3+ame as sender4 Defining Target +#stem for $"C Calls 3Tcode * +MDG4 3+ame as sender4 Defining 1ort3+ame as sender4 Defining 1artner 1rofiles * 6ere 5e are acce0ting the data from +ender s#stem) 6ence 5e need to config%re it as 'nbo%nd)

Clic- on the

sign above to go to ne:t screen)

6ere the message t#0e is to be created again as it 5as created on the sender side) The follo5ing ste0s are re0eated, as done on the sender side, on the receiver end Tcode H!.0 Tcode H!.1 Tcode H!82 Tcode H!81 6ere on the receiver end, 5e need to s0ecif# a 0rocess code at the time of defining the 0artner 0rofile) 1rocess code is something that has the logic defined abo%t 5hat to be done after receiving the 'D(C) 'n o%r case, on recei0t of the 'D(C, 5e are %0dating the Z Table) i)e 'nserting the data from the 'D(C into the Z Table)

Creating a ,rocess Code Tcode & 2E;!

The logic associated is coded in the $unction 'odu e 5hich is s0ecified in the 'dentification "ield above) Also the 0rocessing t#0e is selected as ,rocessing -y $unction 'odu e as above) The f%nction Mod%le is s0ecified in the follo5ing screen)

To have your function Module in the above drop down list, the entry is to be made using the following transaction

TCode & 5D(4

(nce the entr# is done here, the f%nction mod%le a00ears in the dro0 do5n list in the 0revio%s stage)

A so it is im+ortant to ma6e the fo o/ing entry Tcode 2E(<

"%nction Mod%le 5ill loo- something as belo5:

+o%rce Code f%nction z=idoc=in0%t=sach ) ;I,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;I;I ocal interface: ;I 'M1($T'NA ;I 9A >!3'N1>T=M!T6(D4 'J! /DH"A1=1A$,'N1>TM!T6D ;I 9A >!3MA++=1$(C!++'NA4 'J! /DH"A1=1A$,MA++=1$(C ;I 9A >!3N(=A11 'CAT'(N= (A4 'J! +C,DATA$ (1T'(NA

;I 9A >!3MA+++A9!'N"(+4 'J! MA+++A9'N" +T$>CT>$! MA+++A9'N" ;I (1T'(NA ;I !K1($T'NA ;I 9A >!3H($J" (H=$!+> T4 'J! /DH"=1A$AM,$!+> T ;I 9A >!3A11 'CAT'(N=9A$'A/ !4 'J! /DH"=1A$AM,A11 =9A$ ;I 9A >!3'N=>1DAT!=TA+J4 'J! /DH"A1=1A$,>1DAT!TA+J ;I 9A >!3CA =T$AN+ACT'(N=D(N!4 'J! /DH"A1=1A$,CA T$AN+ ;I TA/ !+ ;I 'D(C=C(NT$ +T$>CT>$! !D'DC ;I 'D(C=DATA +T$>CT>$! !D'DD ;I 'D(C=+TAT>+ +T$>CT>$! /D'D(C+TAT ;I $!T>$N=9A$'A/ !+ +T$>CT>$! /DH"$!T9A$ ;I +!$'A 'ZAT'(N='N"( +T$>CT>$! /D'=+!$ ;I !KC!1T'(N+ ;I H$(NA=">NCT'(N=CA !D ;I,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, data:5a=data li-e edidd, it=data li-e table of 5a=data, 5a=cont li-e edidc, it=cont li-e table of 5a=cont, 5a=stat%s li-e bdidocstat, it=stat%s li-e table of 5a=stat%s) data : gen=segment li-e edidd,segnam val%e ?Z+AC6?) data: 5a=em0 li-e zsach1, begin of 5a=em0=tem0, lname li-e zsach1,lname, fname li-e zsach1,fname, end of 5a=em0=tem0) it=data @ idoc=dataLM) it=cont @ idoc=contrlLM) loo0 at it=data into 5a=data) read table it=cont into 5a=cont 5ith -e# docn%m @ 5a=data,docn%m) if s#,s%brc @ 0) if 5a=data,segnam @ gen=segment) 5a=em0=tem0 @ 5a=data,sdata) move,corres0onding 5a=em0=tem0 to 5a=em0) insert zsach1 from 5a=em0) if s#,s%brc @ 0) 5a=stat%s,docn%m @ 5a=data,docn%m) 5a=stat%s,stat%s @ ?D.?) else) 5a=stat%s,docn%m @ 5a=data,docn%m) 5a=stat%s,stat%s @ ?D1?) endif) a00end 5a=stat%s to it=stat%s) clear 5a=stat%s) 'D(C=+TAT>+LM @ 'T=+TAT>+) endif) endif)

endloo0) idoc=stat%sLM @ it=stat%s) endf%nction) .OTE: 2e can a so /rite the a-ove as discussed in C ass

TESTI.= Running the A++ ication Sender system !:ec%te the 0rogram 5e created earlier

Chec-ing the 'D(C T Code 2E"!

Chec6ing the data on the Receiver end Tcode: 2E"!

The 'D(C has arrived here Chec6ing the Data Do%ble clic- on the 'D(C

Chec-ing the Database

This way, the data has come to the receiver end successfully.

Potrebbero piacerti anche