Adapter Services

Overview

Adapter services for Adapter for SAP work by executing a function module residing on an SAP system. A function module performs functions against data in the SAP system.

You can create a service for any function module that is designated for external use (for example: ‘remote enabled'). This includes all BAPIs, which are formalized function modules.

Before you can create an adapter service, you must configure an RFC client connection to the SAP system you want to access. You identify a connection alias and specify information that is required to connect to the SAP system. To create an adapter service, you select the SAP system and the RFC that you want the service to execute. After creating the adapter service, you can create a client that invokes the service.

This chapter describes how to create an adapter service for a specific function module on one specific SAP system and how to test the adapter service.

Note: You must have administrator privileges on Integration Server to create a new RFC connection to an SAP system. If you do not have such privileges, have your Integration Server administrator create the new RFC connection for you.

Creating an Adapter Service that Executes an RFC

To create an adapter service that executes an RFC, select the RFC Adapter Service template. This feature allows the function module to be exposed as a standard service. After you create the adapter service, business partners interested in calling this service can incorporate it into their client code.

Note: Calling a BAPI according to its definition in the BOR is currently not possible as an adapter service. In this case, use the BAPI transport.
Note: Adapter for SAP outbound call is an inbound call from the SAP system's point of view.

Terminology

To use Adapter for SAP successfully, you should understand the following terms and concepts:

Term Description
Export Output parameters of a function module. Output parameters are simple values or structures.
Function Signature Specifications of the import, export, and table parameters of an function module. Also known as a function interface.
Import Input parameter to an RFC. Input parameters are simple values (such as string or number) or structures.
RFC Adapter Service Adapter for SAP terminology for an association between a function module on an SAP system and an adapter service based on the RFC Adapter Service template on Adapter for SAP.
Structure SAP data structure containing one or more fields. This can be thought of as a single row of a table.
Table SAP data structure that is both an import and export to a function. Tables can be created and passed to an RFC. The function module can modify these tables and return them. The tables themselves are no different from relational database tables; they consist of a series of fields and rows of data for these fields.

Creating an RFC Adapter Service

About this task

Use the following procedure to create an RFC adapter service that makes a remote function call to a function module on the SAP system. This example shows how to create an RFC adapter service for RFC_FUNCTION_SEARCH.

Note: Adapter for SAP outbound call is an inbound call from the SAP system's point of view.

To create an adapter service for an RFC

Procedure

  1. Start Designer.
  2. Select New >Adapter Service. and do one of the following:
    • If you are using Designer, be sure the parent namespace is selected and type a name for the adapter service. Click Next.
  3. Select IBM webMethods Adapter for SAP from the list of available adapter types. Click Next.
  4. Select a previously created RFC connection that points to the SAP system that hosts the function module for which you want to create the adapter service. Click Next.
  5. From the list of available templates, select RFC Adapter Service (synchronous) and do one of the following:
    • If you are using Designer, click Finish.
  6. On the Function Search tab, in the Function Pattern field, type all or part of the name of the function module for which you want to create an adapter service. Use pattern-matching characters if you are unsure of the complete name and want Adapter for SAP to search for several RFCs with similar names. For this example, enter RFC_FUNCTION_* in the Function Pattern field.

    Under Function Name, a list of RFCs that match the criteria you specified in the previous step is displayed.

    Select the name of the RFC for which you want to create an adapter service. For this example, RFC_FUNCTION_SEARCH. Leave all other fields at their default values.

  7. Click Save to save your RFC adapter service.

Testing the RFC Adapter Service

About this task

Use the following procedure to test the RFC adapter service you just created.

To test an RFC adapter service for a function module

Procedure

  1. In Designer , open the RFC adapter service you previously created.

    On the Function Search tab, you will see value RFC_FUNCTION_SEARCH in the Function Name field.

  2. On the toolbar, click Run.
  3. Enter RFC_* into field FUNCNAME to specify input. Click OK.

    The results of RFC_FUNCTION_SEARCH will be displayed in the FUNCTIONS table on the Results page of Designer.

Results

After you create an RFC adapter service that executes a function module, you can create other services and clients that invoke the service.

Important: If the execution of the RFC adapter service requires additional access rights or if the adapter service should be executed with a specific SAP user account, you can override the SAP default user and provide the user name and password of a different SAP user account as parameter $user and $pass in the pipeline. These parameters must be set in the pipeline before the adapter service is invoked.
Important: If an optional table is not passed to an RFC adapter service, no values will be returned for that table. To ensure that the optional table gets returned from the SAP system, in your calling service you need to ensure that a value is set at the input signature of the RFC adapter service you want to call. For example, you call an adapter service named TCC_MSS_GET_ERRORLOG from a wrapper flow service. This adapter service contains an optional table called LOGLIST. To pass this table, click Set Value for this parameter.

If the empty table should only be the default value, unselect Overwrite Pipeline Value. With these setting, the optional table is always returned.

Posting an RFC-XML Document from an HTTP Client

There are several possible ways to invoke the RFC adapter service which will call a function module. It is important that you understand the namespace convention for services. (For more information, see IBM webMethods Integration Server Administrator’s Guide for your release. )

You can invoke the service illustrated previously by calling the following URL:

http://<Integration Server>:<port>/invoke/<folder1>.<folder2>/<service>

Invoking the RFC Adapter Service from a Browser

About this task

To invoke the service

Procedure
  1. In an interactive scenario, you can simply call it from a browser the same way you call any other service on Integration Server. The input parameters must then be URL encoded, for example: http://localhost:5555/invoke/app/rfcGetStructureDefinition?TABNAME=USER01

    The response can then be rendered via an HTML template.

  2. In a fully automated scenario your application would, however, send the request XML document to this service. A template for a valid request document for each function module can be generated from the Lookup menu by clicking the RFC-XML button. To invoke the RFC adapter service, you must post it in the HTTP body of request to the URL (as above). Your application must also set some keys in the HTTP Header:
    POST /invoke/<your complete service name> HTTP/1.1   
    --> the service name to be called   
    Host: <xyz>   
    --> host of http client   
    Content-type: application/x-sap.rfc   
    --> you have to set the content type. When sending an RFC-XML   
    document, the content type should be application/x-sap.rfc   
    Cookie: ssnid=<4711>   
    --> This is optional. On the first connect Integration Server will generate 
    a session cookie. When you use this for the following   
    communication you will be assigned to the same Integration Server   
    session. If you do not use the session cookie a new Integration Server   
    session will be created with every HTTP request.   
    Content-Length: <the length of the HTTP Body>
Results

The HTTP Body must consist of the XML document, encoded in RFC-XML. Depending on whether the call was processed successfully, you will get a response or an exception XML document. You can also force Adapter for SAP to invoke the function module with tRFC by setting a transaction ID in the Envelope of the XML document. However, you should bear in mind that only function modules without return parameters can be called with tRFC.

Tip: To simulate a raw post, you can use the service pub.client:http.

Invoking the RFC Adapter Service Using the pub.client.http Service

About this task

To use the pub.client.http service

Procedure
  1. Using Designer , navigate to the pub.client:http service.
  2. Select Test > Run.
  3. Specify the URL of the RFC-XML handler service. For example,

    http://localhost:5555/invoke/app/rfcGetStructureDefinition

  4. Specify Post as the method.
  5. Paste the document into the String field of the Data section.
  6. Add one entry in the field headers:

    Name: Content-type

    Value: application/x-sap.rfc

Results

For more information about the pub.client:http service, see IBM webMethods Integration Server Built-In Services Reference for your release.