example -1 - using fm - master_idoc_distribute.docx

Upload: santosh-vaishya

Post on 08-Mar-2016

36 views

Category:

Documents


5 download

TRANSCRIPT

Example -1 Custom program using FM 'MASTER_IDOC_DISTRIBUTE'

Step - 1 - Go to BD54 and create a logical system for sender and receiver.

LS800 - SenderLS000 Receiver

Step - 2 - Go to SC44, Assign the logical system name against your corresponding client.

800 - LS800000 - LS000

Step - 3 - Go to SM59 in Sender system (Client 800), and press create button.

RFC destination - LS000Connection Type - 3Language - ENClient - 000User - SAPUSERPassword - *******.

Save & Check connectivity. Do Remote logon.

Step - 4 - In receiving system (Client 000) go to SM59, and press create button.

RFC destination - LS800Connection Type - 3Language - ENClient - 000User - SAPUSERPassword - *******.

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)

Short Text - Custom Message Type

Save and Go back.

Step - 7 - Go to transaction code - WE31. Create new segment.Segment Type zcustseg (ZCSEG1) Release No - 701Short Text - Custom Segment Type.

Create segment with the following field.Filed NameData Element

v_kunnrKUNNR

v_name1NAME1

v_ort01ORT01

- Then SAVE and click enter to continue.- Then Go Back.- In the menu bar, EDIT->Set Release. Then Save and Go back.

Step - 7 - Go to transaction code - WE30. Create custom IDOC type.

Obj. Name zcustidoc (ZCIDOC)

Then press create icon.

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.

Message Type zcustmsgtyp (ZCMSGTYP)Basic Type zcustidoc (ZCIDOC)Extension - Leave it blankRelease - (Enter Release version while releasing segment in WE31 transaction) - 701

Step - 9 - Go to transaction code - WE21. To create a custom Port

- 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.

Step - 10 - Go to transaction code - WE20. To create Partner Profile

Partner Type - LS (Logical Systems for ALE)Partner No - LS000 (Name of the Receiver Logical System)Typ - USAgent - SAPUSER

Then Save and go to and OUTBOUND Parameter. Click the + Sign button.

Message Type zcustmsgtyp

In Receiver TabReceiver Port - ZCPORTBasic Type - zcustidocChoose radio button - Transfer IDOC immediately.Choose radio button - Do not start subsystem.Select Syntax check box.

Then SAVE and Go Back.

Step - 11 - Go to transaction code - BD64. To create distribution model.

- Go to change mode.- Click on "Create Model View" button.

Mode Name - ZCUSTMODEL1 (ZCMODELV1)Short Text - Custom Model View.Start Date - End Date -

Now select your "Model View" from the list. Click on "Add Message Type" button. Popup will come -

Sender - LS800Receiver - LS000Message Type - zcustmsgtyp

Enter then SAVE.

- Now in the menu bar, Environment -> Generate Partner Profile. Click on this.

Partner System - LS000.

Execute, then go back twice.

- Now go to menu, Edit-> Modelview->Transport. Click on this.

- Now go to menu, Edit-> Modelview->Distribute. Click on this. Go Back.

Step - 12 - Go to transaction code - SE38. To create custom ABAP program.

Report XXXXXXX

* Table declarationsTABLES: KNA1.

* Data declarationsDATA: it_cust like kna1 occurs 0 WITH HEADER LINE.

* Data declarations For IDOCDATA: 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 ScreensSELECT-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'. " (Receiver Logical System Name)wa_eddidc-rcvprt = 'LS'. " (Standard for ALE)wa_eddidc-direct = 1. " (Direction. 1, for outbound)wa_eddidc-mestyp = ' zcustmsgtyp'. " (Message Type created earlier - WE81)wa_eddidc-idoctp = ' zcustidoc' " (IDOC Type as created earlier- WE30)

*************************************************************************** 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.

At the receiver side

After this logon to the Receiver side and go to run partner profile (WE20).Go to T-code - WE21 to create the port. Also go to BD64.

Then go to WE05 to check if the data received or not.