07-31-2007 10:13 AM
how to create a simple idoc in practice? can you provide an example with full source code?
07-31-2007 10:39 AM
Hi,
Here you go..
report z_idoc_creat_tr .
tables : ekpo,
edidd, " Data record (IDoc)
tbdlst, " Text for logical system
edmsg . "Logical message types
parameters: p_ebeln like ekpo-ebeln.
p_logsys LIKE tbdlst-logsys .
p_mestyp LIKE edmsg-msgtyp DEFAULT 'Z_EKPO'.
data : c_seg1 like edidd-segnam value 'ZSEG1_TR',
c_seg2 like edidd-segnam value 'ZSEG2_TR',
itab_comm_idocs like edidc occurs 0 with header line ,
control_record like edidc.
*Internal Tables
data :
itab_edidd like edidd occurs 0 with header line, "Data record(IDoc)
itab_seg1 LIKE zseg1_tr OCCURS 0 WITH HEADER LINE ,
zseg1_tr structure generated when you define the Segments in WE31
itab_seg2 like zseg2_tr occurs 0 with header line .
zseg2_tr structure generated when you define the Segments in WE31
Work Area
data : seg1 like zseg1_tr, " Header Data
seg2 like zseg2_tr.
select single * from ekpo where ebeln = p_ebeln.
*Build Control Data
control_record-mestyp = 'Z_EKPO' . "p_mestyp .
control_record-idoctp = 'ZIDOC_TR' .
control_record-sndprt = 'LS'.
control_record-sndprn = 'LOGSYS0100' .
control_record-sndpor = 'SAPLT1'.
control_record-rcvprt = 'LS'.
control_record-rcvprn = 'SEND' .
control_record-rcvpor = 'A000000171'.
*Filling the Segment 1 ie.,Purchasing Document Number .
move-corresponding ekpo to seg1.
itab_edidd-segnam = 'ZSEG1_TR'.
itab_edidd-sdata = seg1. " Value for the Segment1.
append itab_edidd .
clear itab_edidd.
*Filling the Segment 2 ie.,Item Number of Purchasing Document.
select * from ekpo into corresponding fields of table itab_seg2 where
ebeln = p_ebeln .
loop at itab_seg2 .
move-corresponding itab_seg2 to seg2.
itab_edidd-segnam = 'ZSEG2_TR'.
itab_edidd-sdata = seg2.
append itab_edidd.
clear itab_edidd.
endloop.
call function MASTER_IDOC_DISTRIBUTE
exporting
master_idoc_control = control_record
OBJ_TYPE = ''
CHNUM = ''
tables
communication_idoc_control = itab_comm_idocs
master_idoc_data = itab_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.
endif.
loop at itab_comm_idocs.
write:/2 'Docs generated', itab_comm_idocs-docnum.
endloop.
Check this link.
http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/IDOC_tutorial.html
Regards
07-31-2007 10:56 AM
HI jackie
Go through the following Steps for Creating IDoc Via ALE
ALE IDOC
Sending System(Outbound ALE Process)
Tcode SALE ? for
a) Define Logical System
b) Assign Client to Logical System
Tcode SM59-RFC Destination
Tcode BD64 ? Create Model View
Tcode BD82 ? Generate partner Profiles & Create Ports
Tcode BD64 ? Distribute the Model view
Message Type MATMAS
Tcode BD10 ? Send Material Data
Tcode WE05 ? Idoc List for watching any Errors
Receiving System(Inbound ALE )
Tcode SALE ? for
a) Define Logical System
b) Assign Client to Logical System
Tcode SM59-RFC Destination
Tcode BD64 ? Check for Model view whether it has distributed or not
Tcode BD82 -- Generate partner Profiles & Create Ports
Tcode BD11 Getting Material Data
Tcode WE05 ? Idoc List for inbound status codes
ALE IDOC Steps
Sending System(Outbound ALE Process)
Tcode SALE ?3 for
a) Define Logical System
b) Assign Client to Logical System
Tcode SM59-RFC Destination
Tcode BD64 !V Create Model View
Tcode BD82 !V Generate partner Profiles & Create Ports
Tcode BD64 !V Distribute the Model view
This is Receiving system Settings
Receiving System(Inbound ALE )
Tcode SALE ?3 for
a) Define Logical System
b) Assign Client to Logical System
Tcode SM59-RFC Destination
Tcode BD64 !V Check for Model view whether it has distributed or not
Tcode BD82 -- Generate partner Profiles & Create Ports
Tcode BD11 Getting Material Data
Tcode WE05 !V Idoc List for inbound status codes
Message Type MATMAS
Tcode BD10 !V Send Material Data
Tcode WE05 !V Idoc List for watching any Errors
1)a Goto Tcode SALE
Click on Sending & Receiving Systems-->Select Logical Systems
Here Define Logical Systems---> Click on Execute Button
go for new entries
1) System Name : ERP000
Description : Sending System
2) System Name : ERP800
Description : Receiving System
press Enter & Save
it will ask Request
if you want new request create new Request orpress continue for transfering the objects
B) goto Tcode SALE
Select Assign Client to Logical Systems-->Execute
000--> Double click on this
Give the following Information
Client : ERP 000
City :
Logical System
Currency
Client role
Save this Data
Step 2) For RFC Creation
Goto Tcode SM59-->Select R/3 Connects
Click on Create Button
RFC Destination Name should be same as partner's logical system name and case sensitive to create the ports automatically while generating the partner profiles
give the information for required fields
RFC Destination : ERP800
Connection type: 3
Description
Target Host : ERP000
System No:000
lan : EN
Client : 800
User : Login User Name
Password:
save this & Test it & RemortLogin
3)
Goto Tcode BD64 -- click on Change mode button
click on create moduleview
short text : xxxxxxxxxxxxxx
Technical Neme : MODEL_ALV
save this & Press ok
select your just created modelview Name :'MODEL_ALV'.
goto add message type
Model Name : MODEL_ALV
sender : ERP000
Receiver : ERP800
Message type :MATMAS
save & Press Enter
4) Goto Tcode BD82
Give Model View : MODEL_ALV
Partner system : ERP800
execute this by press F8 Button
it will gives you sending system port No :A000000015(Like)
5) Goto Tcode BD64
seelct the modelview
goto >edit>modelview-->distribute
press ok & Press enter
6)goto Tcode : BD10 for Material sending
Material : mat_001
Message Type : MATMAS
Logical System : ERP800
and Execute
7)goto Tcode : BD11 for Material Receiving
Material : mat_001
Message Type : MATMAS
and Execute --> 1 request idoc created for message type Matmas
press enter
Here Master Idoc set for Messge type MATMAS-->press Enter
1 Communication Idoc generated for Message Type
this is your IDOC
Change Pointers
I know how to change the description of a material using ALE Change Pointers.
I will give the following few steps
1) Tcode BD61---> check the change pointers activated check box
save and goback.
2) Tcode BD50---> check the MATMAS check box save and comeback.
3) Tcode BD51---> goto IDOC_INPUT_MATMAS01 select the checkbox save and comeback.
4) Tcode BD52---> give message type : matmas press ok button.
select all what ever you want and delete remaining fields.
save & come back.
5) 5) go to Tcode MM02 select one material and try to change the description and save it
it will effects the target systems material desciption will also changes
6) goto Tcode SE38 give program Name is : RBDMIDOC and Execute
give Message type : MATMAS and Executte
ALE/IDOC Status Codes/Messages
-
01 Error --> Idoc Added
30 Error --> Idoc ready for dispatch(ALE Service)
then goto SE38 --> Execute the Program RBDMIDOC
29 Error --> ALE Service Layer
then goto SE38 --> Execute the Program RSEOUT00
03 Error --> Data Passed to Port ok
then goto SE38 --> Execute the Program RBDMOIND
12 Error --> Dispatch ok
Inbound Status Codes
50 Error --> It will go for ALE Service Layer
56 Error --> Idoc with Errors added
51 Error --> Application Document not posted
65 Error --> Error in ALE Service Layer
for 51 or 56 Errors do the following steps
goto WE19 > give the IDOC Number and Execute>
Press on Inbound function Module
for 65 Error --> goto SE38 --> Execute the Program RBDAPP01 then your getting 51 Error
<b>
Regards,
Azhar</b>
07-31-2007 11:53 AM
Try with the follwoing steps
Sending System(Outbound ALE Process)
Tcode SALE ³ for
a) Define Logical System
b) Assign Client to Logical System
Tcode SM59-RFC Destination
Tcode BD64 ¡V Create Model View
Tcode BD82 ¡V Generate partner Profiles & Create Ports
Tcode BD64 ¡V Distribute the Model view
This is Receiving system Settings
Receiving System(Inbound ALE )
Tcode SALE ³ for
a) Define Logical System
b) Assign Client to Logical System
Tcode SM59-RFC Destination
Tcode BD64 ¡V Check for Model view whether it has distributed or not
Tcode BD82 -- Generate partner Profiles & Create Ports
Tcode BD11 Getting Material Data
Tcode WE05 ¡V Idoc List for inbound status codes
Message Type MATMAS
Tcode BD10 ¡V Send Material Data
Tcode WE05 ¡V Idoc List for watching any Errors
1)a Goto Tcode SALE
Click on Sending & Receiving Systems-->Select Logical Systems
Here Define Logical Systems---> Click on Execute Button
go for new entries
1) System Name : ERP000
Description : Sending System
2) System Name : ERP800
Description : Receiving System
press Enter & Save
it will ask Request
if you want new request create new Request orpress continue for transfering the objects
B) goto Tcode SALE
Select Assign Client to Logical Systems-->Execute
000--> Double click on this
Give the following Information
Client : ERP 000
City :
Logical System
Currency
Client role
Save this Data
Step 2) For RFC Creation
Goto Tcode SM59-->Select R/3 Connects
Click on Create Button
RFC Destination Name should be same as partner's logical system name and case sensitive to create the ports automatically while generating the partner profiles
give the information for required fields
RFC Destination : ERP800
Connection type: 3
Description
Target Host : ERP000
System No:000
lan : EN
Client : 800
User : Login User Name
Password:
save this & Test it & RemortLogin
3)
Goto Tcode BD64 -- click on Change mode button
click on create moduleview
short text : xxxxxxxxxxxxxx
Technical Neme : MODEL_ALV
save this & Press ok
select your just created modelview Name :'MODEL_ALV'.
goto add message type
Model Name : MODEL_ALV
sender : ERP000
Receiver : ERP800
Message type :MATMAS
save & Press Enter
4) Goto Tcode BD82
Give Model View : MODEL_ALV
Partner system : ERP800
execute this by press F8 Button
it will gives you sending system port No :A000000015(Like)
5) Goto Tcode BD64
seelct the modelview
goto >edit>modelview-->distribute
press ok & Press enter
6)goto Tcode : BD10 for Material sending
Material : mat_001
Message Type : MATMAS
Logical System : ERP800
and Execute
7)goto Tcode : BD11 for Material Receiving
Material : mat_001
Message Type : MATMAS
and Execute --> 1 request idoc created for message type Matmas
press enter
Thanks & regards
Sreenivas
Here Master Idoc set for Messge type MATMAS-->press Enter
1 Communication Idoc generated for Message Type
this is your IDOC
Take a look at this guide.
http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
http://www.allsaplinks.com/idoc_sample.html
http://www.sappoint.com/abap/ale.pdf
http://www.sappoint.com/abap/ale2.pdf
http://www.sapgenie.com/ale/configuration.htm
http://www.sappoint.com/abap/ale.pdf
http://www.sappoint.com/abap/ale2.pdf
http://www.sapdevelopment.co.uk/training
http://www.sappro.com/downloads/OneClientDistribution.pdf
http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
Create The Extension Segment
Transaction: WE31
The first step in extending an IDoc is to create the new segments that will go into that IDoc. There are some rules that you need to follow when creating the segments:
- The name of each segment type must start with Z1
- For each field in the segment you need to define a field name and a
data element.
- The data element for the segment structure must be of data type CHAR.
How to create new segments:
Run the segment maintenance transaction WE31.
Type your new segment name, and click on Create.
Define the fields of your segment:
Field name
Data Element for the field (from the ABAP dictionary).
Do not change the Export length!
Save the segment
Run Segment -->Check to check the segment for consistency.
Release the segment for transport. Select Edit -->Set Release. Note that the Release column now has a check mark.
Create the Extension IDoc Type
Transaction: WE30
After you create the segments to be added to the extension type, you can create the extension type itself. Execute transaction WE30, enter the extension name, select Extension type, and click Create. You now have three options:
Create new type: Does not refer to other extension types
Create copy: Copies info from an extension type that already exists
Create successor: Extends an extension type from a previous release
of R/3. You can only have one version of an extension type for
each release.
Enter the Basic IDoc type that this extension type will extend.
The screen now shows the structure of the IDoc type you used as
a reference.
Position the cursor on one of the segments and click Create. This will insert an extension segment as a child of the selected segment.
NOTE: A segment cannot appear more than once in an IDoc type! You must control the use of duplicate segments with the segment attributes (the next screen).
The segment attribute screen appears. Enter the information and save.
Extension segments should not be mandatory (for future upgrades), and will need to have minimum and maximum number of instances defined. This answers the question, for each instance of the parent segment, how many instances of the child segment may we have?
You can press the Segment Editor pushbutton to view or change the segment definition.
Create the new Message Type
You can only use an extension IDoc type by assigning it to a message type. You can create a new message type for this.
First the message type itself needs to be created.
Transaction: WE81
Create a new entry and save. Use SAP established customer naming conventions (good form is to start with a Z and retain the rest of the related SAP message type, so, for example, MATMAS becomes ZMATMAS).
After creating the message type, associate it with the corresponding Basic IDoc Type and Extension Type. This relationship is used when IDocs are sent to or received from a partner to determine what segments are valid and what the hierarchy for those segments is.
Transaction: WE82
Create a new entry and enter the Message type, Basic IDoc type, Extension type, and Release, and save your data. Note: the release assignment is not valid for prior SAP releases.
One message type can be associated with many basic IDoc types; however, you need a one-to-one relationship for distribution via ALE.
regards,
srinivas
*reward for useful answers*</b>