Views 417
Visitors 256

Outbound Setting

Home 
| Top Page | Threads |
Previous  Next

Define Logical Systems and Assign Client to Logical System Transaction SALE

SALE-4

 

Go to Define Logical System (See the figure)
Define a new logical system to identify the local system and save it

       SALE-1

 

Now, go to Assign Client to Logical System (See the figure)
Add a new entry
Specify the client, previously created logical system and other attributes
Save the entry

       SALE-2

 

Define a new logical system to identify the partner system and save it

       SALE-3

 

Maintain RFC Destinations Transaction SM59

Create a new RFC destination for R/3 type connection
Specify the target host on Technical settings tab

       SM59-1

Provide the Logon credentials on the Logon/Security tab

       SM59-2

Save the settings
To verify the settings, Click on Test connection or Remote logon

 

Define Ports Transaction WE21

We need to define a tRFC port for the partner system
Click on Transactional RFC node
Create a new port

       WE21-1

Provide a description
Specify the name of the target RFC destination

       WE21-2

Save the object

 

Maintain Distribution Model Transaction BD64

Click on Change BD64-1
Create a new model view BD64-2
Provide a Short text and Technical name to the model view

       BD64-3

       Note : Technical Name sebaiknya namanya sesuai dengan RFC Destinations. Selain itu Technical Name adalah Case Sensitive.

Add message type BD64-5
Specify sender and receiver systems
Also, specify the message type that we created previously

       BD64-4

Save the Distribution model

Note : Setelah Add message type sebaiknya disave dulu, jangan jalankan langkah di bawah ini (Generate/Create Partner Profile) karena akan muncul message "No messages have been defined for the selection conditions in the model".

Generate/Create Partner Profile Transactions BD82/WE20

To generate Partner profiles automatically you may use BD82 or go to BD64 and use the menu path Environment -> Generate partner profiles
oOtherwise, you may use transaction WE20 to create a partner profile

       BD64-6

On selection screen, specify the model view, target system and execute
The result log will be displayed on the next screen

       BD82-1

To verify the partner profile go to WE20
Check the partner profile for the target system

       WE20-1

 

Distribute Model View Transaction BD64

Select the Model View
Go to menu path Edit -> Model View -> DistributeBD64-7
Result log will be displayed on the next screen

       BD64-8

 

Outbound IDoc Generation Program

Create an executable program ZRZ_ORDER_IDOC in SE38. Below, I have described the program logic:

Fetch the data from the DDic tables ZCUSTOMERS, ZSOHEADERS and ZSOITEMS as per the selection criteria
Fill the control record structure of type EDIDC
oSpecify message type, Basic IDoc type, tRFC Port, Partner number and Partner type of the receiver
Fill the data records
oDefine structures like the IDoc segments
oFill the structures with fetched data
oPass the segment name and the above structure to the appropriate fields of EDIDD type structure
oAppend the EDIDD structure to the EDIDD type internal table
Now, call the function module MASTER_IDOC_DISTRIBUTE and pass the IDoc control record structure and data record table
Commit work if return code is zero
Function module returns a table of type EDIDC to provide the details about generated IDoc
Display appropriate log

Source Code

*&---------------------------------------------------------------------*

*& Report  ZYZ_ORDER_IDOC                                              *

*&                                                                     *

*&---------------------------------------------------------------------*

*&                                                                     *

*&                                                                     *

*&---------------------------------------------------------------------*

 

REPORT  zyz_order_idoc                          .

 

PARAMETERS : p_logsys TYPE tbdlst-logsys.

 

DATA : gen_segment1 LIKE edidd-segnam VALUE 'ZYZSEG1',

       gen_segment2 LIKE edidd-segnam VALUE 'ZYZSEG2',

       gen_segment3 LIKE edidd-segnam VALUE 'ZYZSEG3'.

 

DATA : control_dat LIKE edidc,

        gen_data1 LIKE zcustomers,

        gen_data2 LIKE zsoheaders,

        gen_data3 LIKE zsoitems.

 

TABLES : zcustomers, zsoheaders, zsoitems.

 

DATA : BEGIN OF intab1 OCCURS 0.

        INCLUDE STRUCTURE zcustomers.

DATA : END OF intab1.

 

DATA : BEGIN OF intab2 OCCURS 0.

        INCLUDE STRUCTURE zsoheaders.

DATA : END OF intab2.

 

DATA : BEGIN OF intab3 OCCURS 0.

        INCLUDE STRUCTURE zsoitems.

DATA :  netwr LIKE vbap-netwr,

        zmeng LIKE vbap-zmeng.

data : END OF intab3.

 

DATA : int_edidd LIKE edidd OCCURS 0 WITH HEADER LINE,

        int_edidc LIKE edidc OCCURS 0 WITH HEADER LINE.

 

SELECT vbeln kunnr

  INTO CORRESPONDING FIELDS OF TABLE intab2

FROM vbak

WHERE vbeln = '0000005016'.

IF sy-subrc NE 0.

  MESSAGE 'no data' TYPE 'l'.

  EXIT.

ENDIF.

 

 

SELECT kunnr name1 ort01 land1

  INTO CORRESPONDING FIELDS OF TABLE intab1

FROM kna1

  FOR ALL ENTRIES IN intab2

WHERE kunnr = intab2-kunnr.

IF sy-subrc NE 0.

  MESSAGE 'no data' TYPE 'l'.

  EXIT.

ENDIF.

 

 

SELECT vbeln posnr matnr netwr zmeng waerk zieme

  INTO CORRESPONDING FIELDS OF TABLE intab3

FROM vbap

  FOR ALL ENTRIES IN intab2

WHERE vbeln = intab2-vbeln.

IF sy-subrc NE 0.

  MESSAGE 'no data' TYPE 'l'.

  EXIT.

ENDIF.

 

LOOP AT intab3.

  WRITE intab3-netwr TO intab3-netwr_d.

  WRITE intab3-zmeng TO intab3-zmeng_d.

  MODIFY intab3.

ENDLOOP.

 

control_dat-mestyp = 'ZYZSO_MT'.

control_dat-idoctp = 'ZYZORDER'.

control_dat-rcvpor = '810'.

control_dat-rcvprt = 'LS'.

control_dat-rcvprn = p_logsys.

 

 

LOOP AT intab1.

  MOVE-CORRESPONDING intab1 TO gen_data1.

  int_edidd-segnam = gen_segment1.

  int_edidd-sdata = gen_data1.

  APPEND int_edidd.

  CLEAR intab1.

ENDLOOP.

 

LOOP AT intab2.

  MOVE-CORRESPONDING intab2 TO gen_data2.

  int_edidd-segnam = gen_segment2.

  int_edidd-sdata = gen_data2.

  APPEND int_edidd.

  CLEAR intab2.

ENDLOOP.

 

 

LOOP AT intab3.

  gen_data3-vbeln = intab3-vbeln.

  gen_data3-posnr = intab3-posnr.

  gen_data3-matnr = intab3-matnr.

  gen_data3-netwr_d = intab3-netwr_d.

  gen_data3-zmeng_d = intab3-zmeng_d.

  gen_data3-waerk = intab3-waerk.

  gen_data3-zieme = intab3-zieme.

 

  int_edidd-segnam = gen_segment3.

  int_edidd-sdata = gen_data3.

  APPEND int_edidd.

  CLEAR intab3.

ENDLOOP.

 

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

  EXPORTING

    master_idoc_control                  = control_dat

*   OBJ_TYPE                             = ''

*   CHNUM                                = ''

  TABLES

    communication_idoc_control           = int_edidc

    master_idoc_data                     = int_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.

ELSE.

  LOOP AT int_edidc.

    WRITE :/ 'IDOC GENERATED',int_edidc-docnum.

  ENDLOOP.

  COMMIT WORK.

ENDIF.

 

User Threads | New Thread ( Only for Donators )

Threads Last Post Replies Views