In this chapter, we show you how to map different output parameters of an SAP function module to scalar output parameters of a web service operation. Note that the mapping direction is now reversed: From the function module to the web service parameters.

Mapping structure parameters to scalar parameters

The following example shows you how to map a structure parameter of a function module to scalar parameters of a web service operation.

We use the function module BAPI_COMPANYCODE_GETDETAIL as an application. This function module reads company information for a particular company code and lists the results in several structure parameters.

The aim of this scenario is to map the fields CITY, COMP_NAME and COMP from the output structure COMPANYCODE_DETAIL to the scalar output parameters CompanyID, CompName and City of the web service operation.

Create an operation that calls the function module BAPI_COMPANYCODE_GETDETAIL and return to the overview page.

Then define your scalar output parameters.


Close your entries with OK and open the activity dialog. Mapping an output structure to scalar parameters only works via the advanced settings. Go to the Advanced tab and click New under Output Mappings. All defined scalar output parameters are now displayed in the dialog box.
The corresponding fields of the structure parameter COMPANYCODE_DETAIL are now to be mapped to these parameters.


Select the output parameter CompanyID and call the mapping expression. In the Mapping Expression dialog, switch to the tab page Function Parameters and double-click the structure COMPANYCODE_DETAIL.


Under Mapping Expression, you must now define which fields of the structure are to be mapped with the output parameter CompanyID. If you require the field names, look in the SAP output structure of the function module BAPI_COMPANYCODE_GETDETAIL.


The field COMP is to be mapped with the scalar output parameter CompanyID. This process must be added manually as syntax in the Mapping Expression line.

In this example, the command is [“COMP”].ToString ()
Confirm the entries with OK.


Proceed in the same way with the other two parameters. Map the field COMP_NAME to the parameter CompName and the field CITY to the parameter City. There are then three entries under Output Mappings on the Advanced tab.


The mapping of the output parameters is now complete.

Mapping table values to scalar parameters

In the next example, we demonstrate how table values of a function module can be mapped to scalar output parameters of a web service operation.

The BAPI_REQUISITION_CREATE function module serves as an example. This function module is used to create purchase requisitions in SAP. The results of the executed function module are returned in table RETURN. The aim is to map the Message field of the RETURN output table to the ResultMessage output parameter of the web service operation.

First create an operation that calls the function module BAPI_REQUISITION_CREATE and return to the overview page. Then create the output parameter. Open the parameter dialog box and create a new entry with New. Name the parameter ResultMessage. The direction for output parameters is Output.


The next step is to map the value Message of the output table RETURN to the output parameter ResultMessage.
To do this, open the Advanced tab in the activity dialog. It is not possible to perform the following actions in the standard tab.
In the Advanced window you will find the two areas Input Mappings and Output Mappings. The areas should be empty if you have not performed any mapping activities before. Under Output Mappings, click on New to continue mapping the output parameters.


Double-click on the output parameter ResultMessage and click on the button with the three dots to the right of the Mapping Expression line to open the Mapping Expression dialog.


Call the tab Function Parameters and scroll to the table RETURN. Call this table by double-clicking it to set the function parameter in the Mapping Expression field.


The rest of the command syntax must be added manually in the Mapping Expression field. From line 1 of the table, the instance Message is to be written to the output list.

The command is therefore .Rows[0][“Message”].ToString()


Confirm the entries with OK.



The mapping of the output parameters is now complete.