# Generating a SAP BAPI workflow for versions older than v2.0.0

> After the **SAP BAPI** package has been installed, the **SAP Connector** wizard becomes available in UiPath Studio, in the **Design** ribbon tab, in the **Wizards** section.

After the **SAP BAPI** package has been installed, the **SAP Connector** wizard becomes available in UiPath Studio, in the **Design** ribbon tab, in the **Wizards** section.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178580-7e4ba3fd-53dfe9f4.webp)

First, you must create a workflow that establishes a connection to the **SAP** system. After this step is performed, you can invoke multiple BAPI workflows before closing the connection.

The wizard contains 4 sections, as follows:

## Login Credentials

This section requires you to enter the **System Connection Parameters** and **Login Information**.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-183875-1f89b101-f48ab0b3.webp)

For the System Connection Parameters, enter the details of the SAP system you want to connect to in order to extract the BAPI information. The required fields are:

* **Application Server Host**
* **System Number**

For the Login Information, enter the details for the SAP User that is authorized to connect to the above SAP system. The required fields are:

* **Client**
* **User**
* **Password**

You can also specify the language of the SAP system by filling in the **Language** field. Please note that this field should be filled in with a language code (e.g. EN, DE, etc.). The specified language should be installed on the SAP instance you are connecting to. If no language is specified in this field, the default language of the SAP system is used.

Clicking **Connect** indicates if the connection was successful and changes the status to Online.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-183730-05ab8a2f-8642734b.webp)

:::note
If the connection cannot be established, an error message appears. Review and fix the System Connection Parameters or Login Information and retry. If a connection cannot be established successfully, check with your SAP Administrator.
:::

The SAP BAPI Wizard keeps the System Connection Parameters and Login Information values (with the exception of the **Password** field) for the ongoing Studio session.

## Choose BAPI

Enter the name of the BAPI to automate in the **SAP BAPI Name** field. Optionally, also enter a description.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178088-bde391c9-06d18eb3.webp)

Once the **SAP BAPI Name** field is filled in, click **Next**, If the BAPI is found in the repository, then the Wizard navigates to the Arguments screen.

If the BAPI is not found, an error message appears. Please check that the SAP BAPI name you entered is correct and is enabled in the SAP system. Your SAP Administrator should be able to assist if the BAPI cannot be found.

## Select Arguments

The Wizard lists all the arguments for the BAPI, along with the details for each argument such as **Direction** (In, Out, In/Out), **Data Type**, and if the argument is **Mandatory**. Select the arguments that you want to be mapped into the workflow. Arguments marked as Mandatory are always selected for mapping.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-187054-b610888c-52fe2a48.webp)

You can also specify an **Assigned Name** to be used for the **Workflow Argument** in place of the **Technical Name** from the SAP BAPI.

If a BAPI includes complex arguments, such as tables and structures, which in turn contain complex arguments, an Unsupported BAPI exception is thrown. This happens in the cases of the following argument types:

* A table within a table.
* A table within a structure.
* A structure within a structure.
* A structure within a table.

An error is also thrown if a BAPI includes the return argument with a parameter type different than `BAPIRETURN`, `BAPIRETURN1`, `BAPIRET1`, `BAPIRET2`, `BAPIRET2_FIX`.

Clicking **Next** navigates to the **Generate Workflow** screen.

## Generate Workflow

This screen enables you to review the details of your workflow, ensuring you have selected all the arguments that are to be mapped.

  ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-179744-08d2757d-301020dd.webp)

The **Workflow File Path** property field specifies where you want the workflow to be saved.

Clicking **Generate** creates an `.xaml` file at the specified path, with all the options selected in the **Select Arguments** screen.

## Invoking the BAPI Workflow

The **Invoke Workflow File** activity can be used to invoke the SAP BAPI workflow. The **Open SAP Connection** activity must be placed before the invoke activity, as it generates a `SAPConnectionService` variable, which is subsequently used in the SAP BAPI workflow argument named `SAPConnectionService`. This argument should be set in the `SapConnectionService` property field of the **Open SAP Connection** activity.

:::note
Workflows generated with the SAP BAPI pack cannot be invoked when using the **Isolated** property in the **Invoke Workflow File** activity.
:::

Any `Table` type arguments in the BAPI are mapped to `DataTable` arguments and any `Structure` type arguments in the BAPI are mapped to `DataRow` arguments. All other arguments are mapped to basic data types.

Every BAPI Workflow also returns an argument containing the `BapiReturn` structure of the appropriate type.

After the **Invoke Workflow File** activity, a **Close SAP Connection** activity must be used to close the connection to SAP. The connection can be specified by using the same `SAPConnectionService` variable.
