This post describes a user-defined mapping function for SAP XI that performs an RFC lookup using the SAP Mapping Lookup library in a scenario involving purchase orders.
This code builds on previously posted code examples on SDN, including an article by Danny De Roovere (http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70d90a91-3cf4-2a10-d189-bfd37d9c3231).
The code presented here relates specifically to a purchase order scenario involving the BAPI_PO_GETITEMS function module. The purpose of the lookup is to retrieve the value of an attribute of a specific order item (e.g., PRICE_UNIT), given the ID of the order (PURCHASEORDER) and the ID of the order item (PO_ITEM).
Besides serving as a reference for using the a RFC lookup using the SAP Mapping Lookup library, this example also provides some insights into how to parse the retrieved XML document for the desired information.
Inputs: id of document containing list (e.g., PO Number), list item id value (PO item number)
Output: value of list item attribute (e.g., PRICE_UNIT)
Below are the key steps for implementing this lookup function in a mapping
- Create the mapping
- Create new user-defined function (UDF) in mapping
- Provide input parameter information for the UDF
- Provide the libraries used in the code
- Paste the code
- Adjust the code so it runs in your environment and serves your purpose. This includes at least providing changing the SERVICE and CHANNEL_NAME. In addition a different result attribute (in our case PRICE_UNIT) or even an entirely different FUNCTION_MODULE may be specified. The latter may require further adjustments to the rfcXML string!
- Test the mapping