Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI Wrapper

Former Member
0 Likes
995

Want to know BAPI Wrapper in detail.

2 REPLIES 2
Read only

Former Member
0 Likes
732

chk this

Read only

Former Member
0 Likes
732

Hi.

Testing BAPI Wrappers

To check the logic and the implementation of the BAPI wrappers, the following simple ABAP test program can be written for each type of BAPI wrappers (e.g. using the transaction se38):

Bapi Wrapper Type

Call cycle

GetList Call GetList BAPI wrapper

Call GetList BAPI wrapper again and verify the results are the same (header data in Tables parameter)

GetDetail Call GetList BAPI wrapper

Call GetDetail BAPI wrapper and verify the object

Create Call Create BAPI wrapper

Call GetDetail BAPI wrapper and verify the object (header data in Export parameter and items in Tables parameters)

Change Call GetDetail BAPI wrapper, and modify some fields

Call Change BAPI wrapper

Call GetDetail BAPI wrapper and verify the object (header data in Export parameter and items in Tables parameters)

Delete Call Delete BAPI wrapper

Call GetDetail BAPI wrapper and verify that the object is deleted

These tests (other than the test for GetList) simulate what Smart Synchronization performs internally for the corresponding actions in the runtime. Thus, it is important to test each function module not just by single test execution (for example, from the transaction se37) but also by the combination of function modules.

In addition to the functional test above, it is also worth evaluating the performance of each BAPI wrapper function call.

Example

An example unit test program is the report MDK_SST_CONTACT_CREATE_UNITTST that can be found in any SAP system with mySAP Technology 6.20 (as of SP18).

What is a BAPI Wrapper ?

In this section, we will discuss what BAPI Wrapper is and why it is needed.

A BAPI wrapper is a function module more or less like a BAPI and follows certain rules to be a BAPI wrapper. Conceptually, a BAPI wrapper has the role of a private method of a business object (SyncBO) and resides in a backend system. That is, a SyncBO in Smart Synchronization calls the BAPI wrapper based on the request from a mobile device. Therefore, it is important that each BAPI wrapper has the parameters expected by Smart Synchronization and behaves as expected by Smart Synchronization. For each business object, up to 5 BAPI wrappers can be created and used:

BAPI Wrapper

Description

GetList Returns a list of business object header data based on the selection criteria specified in the Import parameters.

GetDetail Returns one header data as Export parameter out of the header data list based on the object key(s) specified in the Import parameters. It also returns one or more list of item entries associated with the header data.

Create Creates a single business object, and returns object key(s).

Change Modifies the header and/or items of the specified business object. The function needs to replace the entire item data with the entries of Tables parameters (For more information, refer to Change function)

Delete Deletes the specified business object (including the items).

The following diagram describes the relationship between the BAPI wrapper parameters and the business objects:

BAPI wrapper is called as such, because it typically wraps an existing standard BAPI. When a standard BAPI is available for the business object of interest, it is strongly recommended to use the BAPI in the BAPI wrapper. This is because SAP guarantees that the interface of BAPIs are stable and they are supported in every version of SAP systems, which results in less maintenance of the BAPI wrapper that uses BAPIs. That is, using BAPIs minimizes the risk to encounter unexpected behavior of a BAPI wrapper due to the changes made in the backend system.

Although it is strongly recommended to use standard BAPIs, if no appropriate BAPI exists, it must be created, or the data access/update logic must be implemented within the BAPI wrapper. Also, there may be cases where a BAPI wrapper needs to call multiple BAPIs, for example, to merge multiple business objects on the backend into one, so that a client application deals with the merged business object, instead of multiple business objects.

The following is some of the main reasons why BAPI wrappers are needed:

To ensure the consistency within the business object by defining Export/Import/Tables parameters of 5 types of BAPI wrappers appropriately, that is, in the way Smart Synchronization expects

To ensure the consistent behavior of the update transaction by ensuring u201CCommit and Waitu201D within BAPI wrappers (Create/Change/Delete)

To provide an appropriate data model for the client (typically a superset of the data model required in the client)

It is important to understand how BAPI wrappers for a business object can be grouped as a SyncBO and what the client view of the SyncBO will be. In most cases, for example, the business object header of a SyncBO will be the structure defined in that of the GetList BAPI wrapperu2019s Tables parameter. Then, the business object header for the client will be the subset of the business object header defined in the SyncBO.

For detailed information of SyncBO, please read section Defining Synchronizer Business Object.

thanks

karthik