---
schema_version: "1"
id: 10743b757ad06622bd7111f81792ce2dadc0b071714083acb66bf6bc32f1d585
title: SAP Custom BAPI Setup Guide
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/retail/latest/sap-custom-bapi-setup-guide.md
canonical_url: https://docs.mulesoft.com/retail/latest/sap-custom-bapi-setup-guide
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 79514700d6ae258e05194b3dd2633c87aa9203680e4b4c2e6a8979183801c326
description: MuleSoft Documentation Site
release: "3.2"
latest: true
---
---
product: Retail
version: 3.2
is-latest-version: true
---

# SAP Custom BAPI Setup Guide

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The following provides guidance on how to use the custom BAPI code (for example,
`ZBAPI_CUSTOMER_V3`) for your SAP instance.

> [!NOTE] You must complete the following instructions before deploying the
> [Customer profile sync from SAP](https://anypoint.mulesoft.com/exchange/org.mule.examples/mulesoft-accelerator-for-retail/minor/3.0/pages/Use%20case%201%20-%20Customer%20profile%20sync/)
> use case.

## BAPI custom objects

You must create the following ABAP objects in order to use this custom BAPI, which are described
below.

### Data Elements

- `Z_MASTER_ID`

See [Creating data elements](#creating-data-elements).

### Structures

- `ZSTR_PERSON`

- `ZSTR_ORGANIZATION`

- `ZSTR_GROUP`

- `ZES_CUSTOMER`

- `ZES_CONTROLDATA`

See [Creating structures](#creating-structures).

### Table Types

- `ZTY_CUSTOMER`

See [Creating table types](#creating-table-types).

### Transparent Tables

- `ZTT_CUSTOMER`

See [Creating transparent tables](#creating-transparent-tables).

### Function Groups

- `ZFG_CUSTOMER`

- `ZFG_CUSTOMER2`

See [Creating function groups and function modules](#creating-function-groups-and-function-modules).

**[ZBAPI\_CUSTOMER modules](#zbapi-customer-modules)**

- `ZBAPI_CUSTOMER`

- `ZBAPI_CUSTOMER_CREATE`

- `ZBAPI_CUSTOMER_CUSTOM_FIELDS`

- `ZBAPI_CUSTOMER_UPDATE`

**[More ZBAPI modules](#more-zbapi-modules)**

- `ZBAPI_QUERY`

- `ZBAPI_ADDR_QUERY`

- `ZBAPI_QUERY_SAP`

- `ZBAPI_CUST_QUERY`

- `ZBAPI_CUSTOMER_CD`

See [Creating function groups and function modules](#creating-function-groups-and-function-modules).

### Creating data elements

<table><colgroup><col> <col></colgroup><thead><tr><th>Object</th><th>How to create</th></tr></thead><tbody><tr><td><p><code>Z_MASTER_ID</code></p></td><td><p><span><img src="https://docs.mulesoft.com/retail/latest/_images/sfc-retail-com-bapi_01.png" alt="SAP data element definition for Z_MASTER_ID" width="599"></span></p></td></tr></tbody></table>

### Creating structures

<table><colgroup><col> <col></colgroup><thead><tr><th>Object</th><th>How to create</th></tr></thead><tbody><tr><td><p><code>ZSTR_PERSON</code></p></td><td><p><span><img src="https://docs.mulesoft.com/retail/latest/_images/retail-2.2-bapi-01.1.png" alt="SAP structure definition for ZSTR_PERSON" width="599"></span></p></td></tr><tr><td><p><code>ZSTR_ORGANIZATION</code></p></td><td><p><span><img src="https://docs.mulesoft.com/retail/latest/_images/retail-2.2-bapi-01.2.png" alt="SAP structure definition for ZSTR_ORGANIZATION" width="599"></span></p></td></tr><tr><td><p><code>ZSTR_GROUP</code></p></td><td><p><span><img src="https://docs.mulesoft.com/retail/latest/_images/retail-2.2-bapi-01.3.png" alt="SAP structure definition for ZSTR_GROUP" width="599"></span></p></td></tr><tr><td><p><code>ZES_CUSTOMER</code></p></td><td><p><span><img src="https://docs.mulesoft.com/retail/latest/_images/retail-2.2-bapi-01.4.png" alt="SAP structure definition for ZES_CUSTOMER" width="599"></span></p></td></tr><tr><td><p><code>ZES_CONTROLDATA</code></p></td><td><p><span><img src="https://docs.mulesoft.com/retail/latest/_images/retail-2.2-bapi-01.5.png" alt="SAP structure definition for ZES_CONTROLDATA" width="599"></span></p></td></tr></tbody></table>

### Creating table types

<table><colgroup><col> <col></colgroup><thead><tr><th>Object</th><th>How to create</th></tr></thead><tbody><tr><td><p><code>ZTY_CUSTOMER</code></p></td><td><p><span><img src="https://docs.mulesoft.com/retail/latest/_images/sfc-retail-com-bapi_05.png" alt="SAP table type definition for ZTY_CUSTOMER" width="599"></span></p></td></tr></tbody></table>

### Creating transparent tables

<table><colgroup><col> <col></colgroup><thead><tr><th>Object</th><th>How to create</th></tr></thead><tbody><tr><td><p><code>ZTT_CUSTOMER</code></p></td><td><p><span><img src="https://docs.mulesoft.com/retail/latest/_images/retail-2.2-bapi-05.1.png" alt="SAP transparent table definition for ZTT_CUSTOMER" width="599"></span></p></td></tr></tbody></table>

---

[back to top](#bapi-custom-objects)

### Creating function groups and function modules

#### **ZBAPI Customer modules**

1.  Create the function group "ZFG\_CUSTOMER\_V3".

2.  Create the function module "ZBAPI\_CUSTOMER\_V3", using "Remote-enable module" as processing
    type:

    ![SAP Create Function Module for ZBAPI\_CUSTOMER\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_06.png)

3.  Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_CUSTOMER\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_07.png)

4.  Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_CUSTOMER\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_08.png)

5.  Copy and paste the code from "ZBAPI\_CUSTOMER\_V3.txt".

6.  Create the function module "ZBAPI\_CUSTOMER\_CREATE\_V3":

    ![SAP Create Function Module for ZBAPI\_CUSTOMER\_CREATE\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_09.png)

7.  Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_CUSTOMER\_CREATE\_V3](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-09.1.png)

8.  Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_CUSTOMER\_CREATE\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_11.png)

9.  Copy and paste the code from "ZBAPI\_CUSTOMER\_CREATE\_V3.txt".

10. Create the function module "ZBAPI\_CUSTOMER\_CUSTOM\_FLDS\_V3":

    ![SAP Create Function Module for ZBAPI\_CUSTOMER\_CUSTOM\_FLDS\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_15.png)

11. Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_CUSTOMER\_CUSTOM\_FLDS\_V3](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-15.1.png)

12. Copy and paste the code from "ZBAPI\_CUSTOMER\_CUSTOM\_FIELDS\_V3.txt".

13. Create the function module "ZBAPI\_CUSTOMER\_UPDATE\_V3":

    ![SAP Create Function Module for ZBAPI\_CUSTOMER\_UPDATE\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_12.png)

14. Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_CUSTOMER\_UPDATE\_V3](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-12.1.png)

15. Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_CUSTOMER\_UPDATE\_V3](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-12.2.png)

16. Copy and paste the code from "ZBAPI\_CUSTOMER\_UPDATE\_V3.txt".

17. Create the function module "ZBAPI\_QUERY\_V3", using "Remote-enable module" as processing type:

    ![SAP Create Function Module for ZBAPI\_QUERY\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_36.png)

18. Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_QUERY\_V3](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-36.1.png)

19. Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_QUERY\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_22.png)

20. Copy and paste the code from "ZBAPI\_QUERY\_V3.txt".

21. Create the function module "ZBAPI\_CONTROL\_DATA\_V3":

    ![SAP Create Function Module for ZBAPI\_CONTROL\_DATA\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_21.png)

22. Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_CONTROL\_DATA\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_24.png)

23. Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_CONTROL\_DATA\_V3](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_19.png)

24. Copy the source code from "ZBAPI\_CONTROL\_DATA\_V3.txt".

25. Activate the entire function group by right-clicking on it in the tree and then selecting
    "Activate":

    ![SAP command to activate the ZFG\_CUSTOMER\_V3 function group](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_35.png)

26. Create the function group "ZFG\_CUSTOMER2".

27. Create the function module "ZBAPI\_ADDR\_QUERY", using "Remote-enable module" as processing
    type:

    ![SAP Create Function Module for ZBAPI\_ADDR\_QUERY](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_17.png)

28. Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_ADDR\_QUERY](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_20.png)

29. Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_ADDR\_QUERY](/mulesoft/current/en-us/retail/latest/_images/sfc-retail-com-bapi_22.png)

30. Copy and paste the code from "ZBAPI\_ADDR\_QUERY.txt".

31. Create the function module "ZBAPI\_CONTROL\_DATA" using the import parameters as follows:

    ![SAP import parameters for ZBAPI\_CONTROL\_DATA](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-22.1.png)

32. Use the export parameters as in the following:

    ![SAP export parameters for ZBAPI\_CONTROL\_DATA](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-22.2.png)

33. Copy the source code from "ZBAPI\_CONTROL\_DATA.txt".

34. Activate the entire function group by right-clicking on it in the tree and selecting 'Activate':

    ![SAP command to activate the ZFG\_CUSTOMER2 function group](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-22.3.png)

35. Complete the following:

36. Create a customer group ZSME (**Logistics - General->Business Partner->Customer->Control->Define
    and Assign Customer Number Ranges**)

37. Create a partner group ZSME (**Cross-Application Components->SAP Business Partner->Business
    Partner->Basic Settings->Number Ranges and Settings**) from the transaction SPRO

38. Synchronize them from the same transaction (**Cross-Application Components->Master Data
    Synchronization->Customer/Vendor Integration->Business Partner Settings->Settings for Customer
    Integration->Assign Keys->Define Number Assignment for Direction BP to Customer**)

    ![SAP customer and partner group configuration for ZSME](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-22.4.png)

#### **More ZBAPI modules**

The following describes how to sufficiently set up your SAP instance in order to use the following
custom BAPIs:

- `ZBAPI_ADDR_QUERY`

- `ZBAPI_QUERY_SAP`

- `ZBAPI_CUST_QUERY`

- `ZBAPI_CUSTOMER_CD`

To create ABAP custom objects, groups, and modules:

1.  Create the same dictionary objects created for the BAPI `ZBAPI_CUSTOMER` using the following
    structure/table type:

    ![SAP dictionary object definition for additional custom BAPIs](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-51.png)

    ![SAP table type definition for additional custom BAPIs](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-52.png)

2.  Create the function group `ZFG_CUSTOMER2`.

3.  Create the function module `ZBAPI_ADDR_QUERY` using 'Remote-enable module' as the processing
    type:

    ![SAP Create Function Module for ZBAPI\_ADDR\_QUERY](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-53.png)

4.  Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_ADDR\_QUERY](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-54.png)

5.  Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_ADDR\_QUERY](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-55.png)

6.  Copy and paste the code from 'ZBAPI\_ADDR\_QUERY.txt'.

7.  Create the function module `ZBAPI_ADDR_SAP` using 'Remote-enable module' as the processing type:

    ![SAP Create Function Module for ZBAPI\_ADDR\_SAP](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-56.png)

8.  Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_ADDR\_SAP](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-57.png)

9.  Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_ADDR\_SAP](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-58.png)

10. Copy and paste the code from 'ZBAPI\_QUERY\_SAP.txt'.

11. Create the function module `ZBAPI_CUST_QUERY` using 'Remote-enable module' as the processing
    type:

    ![SAP Create Function Module for ZBAPI\_CUST\_QUERY](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-59.png)

12. Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_CUST\_QUERY](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-60.png)

13. Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_CUST\_QUERY](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-61.png)

14. Copy and paste the code from 'ZBAPI\_CUST\_QUERY.txt'.

15. Create the function module `ZBAPI_CUSTOMER_CD` using 'Remote-enable module' as the processing
    type:

    ![SAP Create Function Module for ZBAPI\_CUSTOMER\_CD](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-62.png)

16. Complete the import parameters with the following:

    ![SAP import parameters for ZBAPI\_CUSTOMER\_CD](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-63.png)

17. Complete the export parameters with the following:

    ![SAP export parameters for ZBAPI\_CUSTOMER\_CD](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-64.png)

18. Copy and paste the code from 'ZBAPI\_CUSTOMER\_CD.txt'.

19. Activate the entire function group by right-clicking on it in the tree and selecting 'Activate':

    ![SAP command to activate custom BAPI function modules](/mulesoft/current/en-us/retail/latest/_images/retail-2.2-bapi-65.png)

## See Also

- [Prerequisites](https://docs.mulesoft.com/retail/latest/prerequisites)

- [MuleSoft Accelerator for Retail](https://docs.mulesoft.com/retail/latest/)
