Sunday, July 19, 2015

Definition of BAPI

BAPI or Business Application Programming Interface is standardized programming interface that allows external access to business processes and data in SAP System. SAP defines it further object in Business Object Repository (BOR) as methods of SAP business objects or SAP interface types. The BAPIs offer an object-oriented view of business components in the SAP system. They are implemented and stored as RFC enabled function modules in the Function Builder of ABAP Workbench.

The BAPIs are here since 1996 (with R/3 release 4.5*) where the concept was introduced. Having said that BAPIs are RFC enabled function modules is not enough. There are further criteria that BAPI must fulfill. Let's have a look at them.

1. BAPI naming convention - technical name must start with BAPI_*.

2. The BAPI must implement method of an SAP Business Object (e.g. financial document, sales order, etc.)

3. The BAPI must maintain static interface through different version of SAP systems

4. It must be enabled for remote (RFC) execution.

5. It must run to completion without need for any secondary user interaction. There is no connection to SAP via SAP GUI. Therefore complete completion of data changes (if any) is required.

6. The BAPI must handle all errors by itself. If situation potentially may lead to inconsistent state of data an ABAP statement RAISE must not be used. Else it would terminate the function immediately leaving the data and the function processing in undefined state.

7. It must not cause ABAP session change. There must not be used any ABAP statement which may cause current Logical Unit of Work (LUW) within SAP User Roll Area to terminate.


According SAP all 7 criterions are adhered by SAP.  Criterions no 4 - 7 must be followed also by customer while developing custom BAPIs. Moreover only SAP objects can follow criterions 1 - 3.


In closing words I'd like to point out that BAPIs were are not designed to cover API as we traditionally know this term. Even they are very often referred as API they basically do not completely comply with the API definition. Usually SAP BAPIs are missing some of API paradigm (e.g. communication based on web protocols; abstracts consumer from the backend app; placed on wrong abstraction level; functionality is duplicated by several BAPIs doing the same; etc.). Therefore it is important that we look at the BAPI as evolution that happened in SAP while striving to enable external data access.


Useful information:
BAPI User Guide (CA-BFA)


No comments: