Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

program logic for IDoc

Former Member
0 Likes
1,758

hi everyone,

I am new to IDoc. Through some forums i came to know that we need to create

segment in we30

idoctype in we31

i understand the above two

msgtype in we80

attaching msgtype to idoctype in we81

i didnt understand how to do the above two, and also i want to know what to do next..like how to do the program

my mailID is karthick9@gmail.com(for any materials if u have)

Regards,

Venkata

Points will be rewarded to answers given

Message was edited by:

venkata k

1 ACCEPTED SOLUTION
Read only

gajendra_bhakuni
Product and Topic Expert
Product and Topic Expert
0 Likes
1,306

Hi Venkat,

From you query it seems that you want to create your own IDoc type and message type.

The process goes as follows:

1) The IDoc structure (segments, fields within segment and hierarchy) is defined in WE30 and WE31. You should check thoroughly within SAP provided standard IDoc type before going ahead to create your own IDoc type.

2) Now you need to create a logical definition for the IDoc type i.e. create a message type. SAP has provided this concept (one more abstraction level) so that the same IDoc type can be used in multiple scenarios without confusion and separate one business process from another. For this you need to create a message type in WE81.

3) Now in WE82 a link between message type and IDoc type is create. Standalone message type has no meaning. We need to attached IDoc type to the message type.

4) After this a parter profile need to be created. SALE area menu can lead to the creation of new Logical system. You can also use an existing logical system.

In WE20 (partner profile definition) correspondin to the logical system for outbound (sending out IDocs) parameters you need to add the message type and define details for the same.

Note the port definition can be created via WE21 and the RFC destination that the port used can be created via SM59. You need to check what type of port is needed. These steps are required for outbound IDoc scenarios.

5) Finally you need to create a program to create IDocs. Within the program you need to fill the control (with the partner profile record that you created earlier) and data segment of the IDoc (the IDoc definition that you created in WE30 and WE31). These are internal tables.

Finally a call to FM -> MASTER_IDOC_DISTRIBUTE which will trigger the IDoc.

Hope this helps.

Regards,

Gajendra.

3 REPLIES 3
Read only

gajendra_bhakuni
Product and Topic Expert
Product and Topic Expert
0 Likes
1,307

Hi Venkat,

From you query it seems that you want to create your own IDoc type and message type.

The process goes as follows:

1) The IDoc structure (segments, fields within segment and hierarchy) is defined in WE30 and WE31. You should check thoroughly within SAP provided standard IDoc type before going ahead to create your own IDoc type.

2) Now you need to create a logical definition for the IDoc type i.e. create a message type. SAP has provided this concept (one more abstraction level) so that the same IDoc type can be used in multiple scenarios without confusion and separate one business process from another. For this you need to create a message type in WE81.

3) Now in WE82 a link between message type and IDoc type is create. Standalone message type has no meaning. We need to attached IDoc type to the message type.

4) After this a parter profile need to be created. SALE area menu can lead to the creation of new Logical system. You can also use an existing logical system.

In WE20 (partner profile definition) correspondin to the logical system for outbound (sending out IDocs) parameters you need to add the message type and define details for the same.

Note the port definition can be created via WE21 and the RFC destination that the port used can be created via SM59. You need to check what type of port is needed. These steps are required for outbound IDoc scenarios.

5) Finally you need to create a program to create IDocs. Within the program you need to fill the control (with the partner profile record that you created earlier) and data segment of the IDoc (the IDoc definition that you created in WE30 and WE31). These are internal tables.

Finally a call to FM -> MASTER_IDOC_DISTRIBUTE which will trigger the IDoc.

Hope this helps.

Regards,

Gajendra.

Read only

0 Likes
1,306

Gajendra, thanks a lot, can u give some examples so that it will be easy for me to understand

Read only

0 Likes
1,306

One very simple code:

==============================

*abap program to generate a customized idoc and send it to the target *system.

REPORT z_b8_ale .

TABLES : ekko,ekpo.

***Data Declaration for IDOC Begin

DATA : v_master_control LIKE edidc.

DATA : BEGIN OF int_idoc_data OCCURS 0.

INCLUDE STRUCTURE edidd.

DATA : END OF int_idoc_data.

DATA : BEGIN OF int_comm_control OCCURS 0.

INCLUDE STRUCTURE edidd.

DATA : END OF int_comm_control.

DATA : BEGIN OF itab OCCURS 10,

lifnr LIKE ekko-lifnr,

ekorg LIKE ekko-ekorg,

ekgrp LIKE ekko-ekgrp,

kdate LIKE ekko-kdate,

ematn LIKE ekpo-ematn,

ktmng LIKE ekpo-ktmng,

meins LIKE ekpo-meins,

netpr LIKE ekpo-netpr,

werks LIKE ekpo-werks,

peinh LIKE ekpo-peinh,

END OF itab.

DATA : str LIKE edidd-sdata,

sagrnum(10) TYPE c VALUE '5500000019'.

DATA:itab1 LIKE ekko OCCURS 0 WITH HEADER LINE,

itab2 LIKE ekpo OCCURS 0 WITH HEADER LINE.

***Data Declaration for IDOC End

****FILL_MASTER_CONTROL

CLEAR v_master_control.

v_master_control-rcvpor = 'ZPORTB8'.

v_master_control-rcvprt = 'LS'.

v_master_control-rcvprn = 'D12503'.

v_master_control-mestyp = 'ZSCHB5'.

v_master_control-idoctp = 'ZSCHIDOC'.

****FILL_IDOC_DATA

CLEAR int_idoc_data.

REFRESH int_idoc_data.

int_idoc_data-segnam = 'ZSCHDLAGR'.

SELECT single * INTO itab1 from ekko WHERE ebeln = sagrnum.

SELECT single * INTO itab2 from ekpo WHERE ebeln = sagrnum.

MOVE itab1-lifnr TO str+0(10).

MOVE itab1-ekorg TO str+10(4).

MOVE itab1-ekgrp TO str+14(3).

MOVE itab1-kdate TO str+17(8).

MOVE itab2-ematn TO str+25(18).

MOVE itab2-ktmng TO str+43(16).

MOVE itab2-meins TO str+59(3).

MOVE itab2-netpr TO str+62(13).

MOVE itab2-werks TO str+74(5).

MOVE itab2-peinh TO str+80(5).

int_idoc_data-sdata = str.

APPEND int_idoc_data.

write : / str.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

EXPORTING

master_idoc_control = v_master_control

TABLES

communication_idoc_control = int_comm_control

master_idoc_data = int_idoc_data

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.

WRITE : / 'IDOC Number created : ', int_comm_control-docnum.

Regards,

Gajendra.