Browse, search, and get metadata for BAPI operations in SAP

This section provides instructions on how to browse, search, and retrieve metadata from SAP for BAPI operations using Add Adapter Service Reference Plug-in, Add Adapter Metadata Wizard, or Consume Adapter Service Add-in. Most of the instructions are same for all three user interface. Wherever applicable, separate procedures are provided for the relevant user interface.

Before performing the steps provided in the following sections, you must have:

  • Created a Visual Studio project.

  • Connected to the SAP system using Consume Adapter Service Add-in, Add Adapter Metadata Wizard, or Add Adapter Service Reference Plug-in. For instructions see Connect to the SAP System in Visual Studio.

Browsing BAPIs in an SAP System

While browsing metadata using Consume Adapter Service Add-in, Add Adapter Metadata Wizard, or Add Adapter Service Reference Plug-in the SAP adapter surfaces BAPIs as business objects and as RFCs. Browsing BAPIs as RFCs is similar to browsing an RFC in an SAP system. In such a case, the BAPIs are available as RFCs under the RFC. For more information on browsing RFCs, see Browse, search, and get metadata for RFC operations in SAP.

This section provides information on browsing BAPIs as business objects. Fore more information about browsing SAP metadata, see How Does the Adapter Surface SAP Metadata?

Perform the following steps to browse BAPIs in an SAP system using the Consume Adapter Service Add-in, Add Adapter Metadata Wizard, or Add Adapter Service Reference Plug-in.

To browse BAPIs in an SAP system

  1. Connect to an SAP server using the Consume Adapter Service Add-in, Add Adapter Metadata Wizard, or Add Adapter Service Reference Plug-in. See Connect to the SAP System in Visual Studio for instructions.

  2. From the Select contract type drop-down list, select the type of contract based on whether you will be performing inbound or outbound operations using the adapter.

  3. In the Select a category box, click the BAPI node to see the BAPI functional areas in the Available categories and operations box. Alternatively, you can also see the BAPI functional areas by expanding the BAPI node.

    Tip

    You can directly go to the “immediate” category node or subcategory nodes in the tree, by typing the name of the artifact in while the focus is on the tree view in the Select a category box. For example, to jump to the Controlling BAPI functional area, keep the focus on the BAPI node, and then type Controlling.

    The following figure shows the Consume Adapter Service Add-in listing the BAPI functional areas.

    Browsing functional areas in a BAPI

  4. Click the BAPI functional area to see the further categorizations of BAPI functional area.

  5. Click the BAPI functional area to see the relevant operations supported for that functional area. The following figure shows the Consume Adapter Service Add-in with the operations supported for a particular functional area.

    Browsing operations for a BAPI

Searching BAPIs in an SAP System

While searching metadata for BAPIs in an SAP system using Consume Adapter Service Add-in, Add Adapter Metadata Wizard, or Add Adapter Service Reference Plug-in the SAP adapter:

  • Supports wildcard characters in the search expression.

  • Enables search immediately under the node at which the search operation is performed.

    The following table lists the special characters that can be used for search and their interpretation by the SAP adapter.

Special character Interpretation
+ (plus) Matches exactly one character.

For example, A+ matches AB, AC, AD
* (asterisk) Matches zero or more characters.

For example, A* matches A, AB, ABC.

For more information about the special characters supported by the adapter, see How Does the Adapter Surface SAP Metadata?

Perform the following steps to search BAPIs in an SAP system using the Consume Adapter Service Add-in, Add Adapter Metadata Wizard, or Add Adapter Service Reference Plug-in.

To search BAPIs in an SAP system

  1. Connect to an SAP server using the Consume Adapter Service Add-in, Add Adapter Metadata Wizard, or Add Adapter Service Reference Plug-in. See Connect to the SAP System in Visual Studio for instructions.

  2. From the Select contract type drop-down list, select the type of contract based on whether you will be searching for inbound or outbound operations using the adapter.

  3. In the Select a category box, click the BAPI functional area containing the BAPI you want to search.

    Note

    You can search for BAPIs only at the root level.

  4. In the Search in category text box, enter a search expression to search for a specific BAPI. For example, to search for BAPIs that have "Account" in their names, type *Account* in the text box.

  5. Click the button with the right-arrow icon to start the search. After the search is complete, the Available categories and operations box lists the BAPIs that satisfy the search criteria.

  6. The following figure shows the Consume Adapter Service Add-in listing the BAPI search result.

    Search BAPIs in an SAP system

Generating Schema for BizTalk Projects

You can use the Consume Adapter Service Add-in or Add Adapter Metadata Wizard to generate schema for selected SAP artifacts. Once you have browsed and searched for the artifacts you want to invoke, you can generate schema for those artifacts and send messages, conforming to the schema, to the SAP system.

Note

You can select category nodes to return all the operations in that category's sub-tree—for example, you can select an entire BAPI sub-functional are (to generate schema for all the BAPIs in that group) or select specific BAPIs to generate schema for only those BAPIs. For more information about the nodes, see Metadata Node IDs4.

To retrieve metadata for BAPIs

  1. Connect to an SAP server using the Consume Adapter Service Add-in or Add Adapter Metadata Wizard. See Connect to the SAP System in Visual Studio for instructions.

  2. From the Select contract type drop-down list, select the type of contract based on whether you will be performing inbound or outbound operations using the adapter.

  3. In the Select a category box, click the BAPI functional group containing the BAPI for which you want to generate metadata.

  4. In the Available categories and operations box, select the functional areas or operations for which you want to generate metadata and click Add. The selected functional areas or operations are listed in the Added categories and operations box.

    The following figure shows the Consume Adapter Service Add-in listing the selected BAPIs.

    Retrieve metadata for a BAPI

    If you want to generate schema for multiple operations, there may be some duplicate element definitions among these schema that may cause failure in compiling the BizTalk project. For example, consider a scenario where you generate schema for an operation “Op1”. The schema for “Op1” contains a parameter of complex data type “CT1”. After generating the schema for “Op1” you close the Consume Adapter Service Add-in and re-open it to generate schema for another operation “Op2”. Assume that “Op2” also contains a parameter of complex data type “CT1”. After you exit the Consume Adapter Service Add-in and compile the project, you will get compilation errors because the complex data type “CT1” is defined twice in different XSD files. In such situations, we recommend the following:

    • Generate schema for all the operations in a single run of Consume Adapter Service Add-in. This ensures that the Consume Adapter Service Add-in generates only one definition for the complex data type “CT1”.

    • If you want to generate schema for multiple operations across different runs of Consume Adapter Service Add-in, make sure you select the Generate unique schema types check box so that the generated XSD files contain unique namespaces for the complex data type “CT1”.

  5. Click OK. The schema file is saved with an .xsd extension at the same location as the BizTalk project.

    Note

    If you are using Consume Adapter Service Add-in, by default the files are created with the naming convention "SAPBinding<n>.xsd", where 'n' can be 1, 2, etc. depending on the number of schema files created. Alternatively, you can provide a custom name to the schema files by entering a name in the Filename prefix text box. The Consume Adapter Service Add-in now creates schema files with the naming convention <filename prefix><n>.xsd.

    Note

    The Consume Adapter Service Add-in also creates a binding file (an XML file) containing the binding properties that you specified while generating the schema for an operation and the SOAP action to invoke the operation. You can import this binding file in the BizTalk Server Administration console to create a WCF-Custom port with the connection URI, binding properties, and the SOAP action set. For more information, see Configure a physical port binding using a port binding file to SAP.

  6. On the File menu, click Save All.

Generating a WCF Client for BAPI Operations Using the Add Adapter Service Reference Plug-in

You can use the Add Adapter Service Reference Plug-in to generate WCF client code for BAPI operations (inbound operations are not supported for BAPIs).

To generate a WCF client for BAPIs

  1. In the Add Adapter Service Reference Plug-in, from the Select contract type drop-down list, select Client (Outbound operations).

  2. In the Select a category box, expand the BAPI node, and then browse or search for the BAPI categories or operations for which you want to generate a WCF client.

  3. In the Available categories and operations box, select the operations or categories (BAPI functional groups) for which you want to generate a WCF client, and then click Add. The selected operations are listed in the Added categories and operations box. You can select any node that is listed in the Available categories and operations box. If you select a category node, then all of the operations available under that node and its sub-nodes will be selected.

    Important

    The Add Adapter Service Reference Plug-in generates a unique WCF client class for each business object. Depending on the categories and operations that you select, more than one WCF client class may be generated. For more information, see Generate a WCF client or a WCF service contract for SAP solution artifacts.

  4. For most scenarios the default serialization options are sufficient; however, if needed, you can control several aspects about the code that is generated and the type of serializer that is used. To set these options:

    1. Click Advanced Options to open the Advanced Options box.

    2. In the Advanced Options box under Choose options for generated proxy, select the options that you want. For example, you can select whether asynchronous methods are generated for the WCF client or disable the generation of a configuration file.

    3. Under Serializer select the serializer that should be used.

      The following figure shows the Advanced Options box with the default selections (Auto is selected for the serializer and no other options are selected).

      The Advanced Options box default settings

      The options that you can configure in the Advanced Options box are equivalent to some of the options available when you use the ServiceModel Metadata Utility Tool (svcutil.exe). For more information about these options, see ServiceModel Metadata Utility Tool (Svcutil.exe).

  5. Click OK. The Add Adapter Service Reference Plug-in saves the WCF client class and helper code in your project directory for the selected operations and categories. By default, a configuration file is also saved. For more information, see Generate a WCF client or a WCF service contract for SAP solution artifacts.

See Also

Get Metadata for SAP Operations in Visual Studio