You are on page 1of 27

IDOC

1. IDOC ........................................................................................................................... 2
2. IDOC............................................................................................................................ 8
3........................................................................................................ 13
4. ....................................................................................................... 17
5.................................................................................................................................... 21
6................................................................................................................................ 22
7.................................................................................................................................... 27

1. IDOC

1.1 ZIDOC_LOG

IDOC
IDOC

1.2WE31 ZMKAL IDOC

1.3WE30 ZMKAL_IDOC ZMKAL

1.4 WE81 MKAL_IDOC


1.5WE82 MKAL_IDOC MKAL_IDOC
1.6 IDOC ZMKAL_LINE

,ZMKAL_TYP, ZMKAL_LINE
1.7 IDOC ZMKAL_IDOC_SEND,
,
FUNCTION zmkal_idoc_send .
*"-------------------------------------------------------------------
---
*"*"Local interface:
*" TABLES
*" ZMKAL TYPE ZMKAL_TYP
*" EXCEPTIONS
*" NO_IDOC
*" NO_MODEL
*"-------------------------------------------------------------------
---

*variables of general interest


DATA:
*control record for the IDoc
idoc_control LIKE edidc,
*data records for the IDoc
t_idoc_data LIKE edidd OCCURS 0 WITH HEADER LINE,
*table for the IDocs created by MASTER_IDOC_CONTROL
t_comm_control LIKE edidc OCCURS 0 WITH HEADER LINE,
*partner type for logical system
c_partner_type_logical_system LIKE edidc-rcvprt,
*help variable for the check if an IDoc has to be created
h_create_idoc.
* variables specific for this example
DATA:
* field strings with IDoc segment structure
e1xmkal TYPE zmkal_line,
* data to be put to the control record
c_message_type LIKE edidc-mestyp VALUE 'ZMKAL_IDOC',
c_base_idoc_type LIKE edidc-idoctp VALUE 'ZMKAL_IDOC',
* segment types to be put to the data record table
c_header_segtyp LIKE edidd-segnam VALUE 'ZMKAL'.

* check if an IDoc has to be created, read the distribution model


CALL FUNCTION 'ALE_MODEL_DETERMINE_IF_TO_SEND'
EXPORTING
message_type = c_message_type
* SENDING_SYSTEM = ' '
* RECEIVING_SYSTEM = ' '
* VALIDDATE = SY-DATUM
IMPORTING
idoc_must_be_sent = h_create_idoc.
* exceptions
* own_system_not_defined = 1
* others = 2.

IF h_create_idoc IS INITIAL.
raise no_model.
* no message flow maintained in the model, nothing to do
EXIT.
ENDIF.

* put the application header record to the IDoc

LOOP AT zmkal.
MOVE-CORRESPONDING zmkal TO e1xmkal.
* append record to IDoc data table
t_idoc_data-segnam = c_header_segtyp.
t_idoc_data-sdata = e1xmkal.
APPEND t_idoc_data.
ENDLOOP.

idoc_control-mestyp = c_message_type.
idoc_control-idoctp = c_base_idoc_type.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'


* in update task "if application document is posted in update task
EXPORTING
master_idoc_control = idoc_control
TABLES
communication_idoc_control = t_comm_control
master_idoc_data = t_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.

* A commit work has to be done. It could also be done in the calling


* application.
COMMIT WORK.

READ TABLE t_comm_control INDEX 1.


IF sy-subrc <> 0.
raise no_idoc.
* no IDoc was created, you can react here, if neccessary
ENDIF.

ENDFUNCTION.

1.8 zmkal_idoc_send
IDOC
2. IDOC

2.1 ZE1PLPOL_TEXT IDOC

2.2 ZLOIROU02

LOIROU02
E1PLPOL
2.3 WE82 LOIROU

ZLOIROU02
TCODE
3.
3.1 WE21

idoc

3.2 / IDOC
SALE

rfc
sap

RFC

4.

4.1

SAP
LOIROU

BOMMAT BOM BOM


CREMAS
DEBMAS
LOIBOM
LOIPLO
LOIROU
MATMAS
ZMKAL_IDOC Product Version IDOC


ZFILEXML ZXML IDOC XML
WE20

5.

5.1 ALE BOM

BD50

BOMMAT BOM BOM
CREMAS
DEBMAS
MATMAS
SALE

6.


IDOC
IDOC
7.

IDOC
02:

T-CODEBD83

30:

T-CODEWE14

You might also like