Data from custom tables (created in customer namespace) is to be formatted into an IDoc and sent from one SAP R/3 system to another using ALE service. We need to have two instances of SAP R/3 systems or we can simulate this on two clients of the same SAP R/3 system.
- Create a segment ZRZSEG1
- Add all fields of table ZCUSTOMERS to it
- Save the segment
- Release it using the menu path Edit -> Set Release
- Similarly create two more segments given below
- Seg. ZRZSEG2 – to hold all fields of table ZSOHEADERS
- Seg. ZRZSEG3 – to hold all fields of table ZSOITEMS
- Create a Basic type ZRZORDER
- Add the created segments in the hierarchy shown
- Maintain attributes for each of the segments
- Save the object and go back
- Release the object using the menu path Edit -> Set Release
- Go to WE81
- Create a new Message type ZRZSO_MT
- Save the object
- Go to WE82 and create new entry
- Assign the message type ZRZSO_MT to the basic type ZRZORDER
- Also specify the Release Version
- Save the object
Outbound Settings
Define Logical Systems and Assign Client to Logical System – Transaction SALE
- Go to Define Logical System (See the figure)
- Define a new logical system to identify the local system and save it
- 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
- Define a new logical system to identify the partner system and save it
- Create a new RFC destination for R/3 type connection
- Specify the target host on Technical settings tab
- Provide the Logon credentials on the Logon/Security tab
- Save the settings
- To verify the settings, Click on Test connection or Remote logon
- We need to define a tRFC port for the partner system
- Click on Transactional RFC node
- Create a new port
- Provide a description
- Specify the name of the target RFC destination
- Save the object
- Click on Change
- Create a new model view
- Provide a Short text and Technical name to the model view
- Add message type
- Specify sender and receiver systems
- Also, specify the message type that we created previously
- Save the Distribution model
- To generate Partner profiles automatically you may use BD82 or go to BD64 and use the menu path Environment -> Generate partner profiles
- On selection screen, specify the model view, target system and execute
- The result log will be displayed on the next screen
- To verify the partner profile go to WE20
- Check the partner profile for the target system
- Select the Model View
- Go to menu path Edit -> Model View -> Distribute
- Result log will be displayed on the next screen
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
- Fill the data records
- 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
Inbound IDoc Posting Function Module
In the receiving system, create a function module Z_IDOC_INPUT_ZRZSO_MT using SE37. Below, I have described the logic for the same.
Add Include MBDCONWF. This include contains predefined ALE constants.
Loop at EDIDC table
- Check if the message type is ZRZORDER. Otherwise raise WRONG_FUNCTION_CALLED exception
- Loop at EDIDD table
- Update the DDic tables from internal tables
- Depending on the result of the update, fill the IDoc status record (type BDIDOCSTAT) and append it to the corresponding table.
- Define Logical Systems – Transaction SALE (Please refer to Outbound Settings)
- Assign Client to Logical System – Transaction SALE (Please refer to Outbound Settings)
- Maintain RFC Destinations – Transaction SM59 (Please refer to Outbound Settings)
- Define Ports – Transaction WE21 (Please refer to Outbound Settings)
- Generate/Create Partner Profile – Transactions BD82/WE20 (Please refer to Outbound Settings)
- Assign Function Module to Logical message – Transaction WE57
- Define Input method for Inbound Function Module – Transaction BD51
- Create a Process Code – Transaction WE42
- Create a new Process Code ZPCRZ
- Select Processing with ALE Service
- Choose Processing type as Processing by function module
- Save the entry
- On the next screen, select your function module from the list
- Save the changes
- Now you will be taken to the next screen
- Double-click on Logical message
- In the Assignment to logical message, specify the message type ZRZSO_MT
- Save the changes
On the sender system, execute the IDoc Generation Program. Check the status of IDoc using transaction WE02.
Check the status of the IDoc in the receiver system using transaction WE02. You can also check the contents of DDic tables to make sure that the records have been created in the receiver system.
Thus to summarize we have learned how to:
No comments:
Post a Comment