Example - 1 - Using FM - MASTER - IDOC - DISTRIBUTE
Example - 1 - Using FM - MASTER - IDOC - DISTRIBUTE
Example - 1 - Using FM - MASTER - IDOC - DISTRIBUTE
Step - 1 - Go to BD54 and create a logical system for sender and receiver.
LS800 - Sender
LS000 Receiver
Step - 2 - Go to SC44, Assign the logical system name against your corresponding client.
800 - LS800
000 - LS000
Step - 3 - Go to SM59 in Sender system (Client 800), and press create button.
RFC destination - LS000
Connection Type - 3
Language - EN
Client - 000
User - SAPUSER
Password - *******.
Save & Check connectivity. Do Remote logon.
Step - 4 - In receiving system (Client 000) go to SM59, and press create button.
RFC destination - LS800
Connection Type - 3
Language - EN
Client - 000
User - SAPUSER
Password - *******.
Save & Check connectivity. Do Remote logon.
Step - 5 - Now logoff Client 000 and re-login to client 800.
Step - 6 - Go to transaction code - WE81. Create new entries for message type.
Message Type zcustmsgtyp (ZCMSGTYP)
v_name1
NAME1
v_ort01
ORT01
- Then SAVE and click enter to continue.
- Then Go Back.
- In the menu bar, EDIT->Set Release. Then Save and Go back.
(ZCIDOC)
Give description on the popup window as - "Custom IDOC Structure", and press Enter.
Click on 'zcustidoc' and then press "Create Segment" button.
Popup will come, give the name of segment type zcustseg (ZCSEG1), as you created earlier
Minimum Number - 1
Maximum Number - 999
- This is a segment no. you can give any range for default.
Then press Enter, Save and Go back.
Step - 8 - Go to transaction code - WE82. Click on change icon and then create a new entries.
Select "transactional RFC" to create a port for ALE. Select and press create button.
Give the name of port - ZCPORT
RFC Destination - LS000.
Then SAVE.
In Receiver Tab
Receiver Port - ZCPORT
Basic Type - zcustidoc
Choose radio button - Transfer IDOC immediately.
Choose radio button - Do not start subsystem.
Select Syntax check box.
Then SAVE and Go Back.
Now select your "Model View" from the list. Click on "Add Message Type" button. Popup will come
Sender - LS800
Receiver - LS000
Message Type - zcustmsgtyp
Go Back.
Report XXXXXXX
* Table declarations
TABLES: KNA1.
* Data declarations
DATA: it_cust like kna1 occurs 0 WITH HEADER LINE.
* Data declarations For IDOC
DATA: it_eddidc LIKE edidc OCCURS 0 WITH HEADER LINE.
DATA: it_eddidd LIKE edidd OCCURS 0 WITH HEADER LINE.
DATA: wa_eddidc LIKE edidc.
DATA: wa_segment like zcustseg.
* Selection Screens
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr.
START-OF-SELECTION.
SELECT * FROM kna1 INTO TABLE it_cust WHERE kunnr IN s_kunnr.
IF sy-subrc eq 0.
**************************************************************************
* Update control record.
**************************************************************************
wa_eddidc-rcvpor = ZCPORT.
" (Port Name)
wa_eddidc-rcvprn = 'LS000'.
wa_eddidc-rcvprt = 'LS'.
wa_eddidc-direct = 1.
wa_eddidc-mestyp = ' zcustmsgtyp'.
wa_eddidc-idoctp = ' zcustidoc'
**************************************************************************
* Built Data Record.
**************************************************************************
LOOP AT it_cust.
MOVE: it_cust-kunnr TO wa_segment-v_kunnr.
MOVE: it_cust-name1 TO wa_segment-v_name1.
MOVE: it_cust-ort01 TO wa_segment-v_ort01.
MOVE: ' zcustseg' TO it_eddidd-segname.
MOVE: wa_segment TO it_eddidd-sdata.
APPEND it_eddidd.
CLEAR it_eddidd.
ENDLOOP.
ENDIF.
**************************************************************************
** Now call function 'MASTER_IDOC_DISTRIBUTE'.
**************************************************************************
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control
= wa_eddidc
TABLES
communication_idoc_control = it_eddidc
master_idoc_data
= it_eddidd
EXCEPTIONS
error_in_idoc_control
=1
error_writing_idoc_status
=2
error_in_idoc_data
=3
sending_logical_system_unkown = 4
others
=5
IF sy-subrc <>0.
ENDIF.
READ TABEL it_eddidc INDEX 1.
WRITE: /it_eddic-docnum.
CLEAR it_eddidc.
Now using T-Code WE05 (at sender side), check that the record went or not.