Thursday, August 30, 2018

BAPI TUTORIAL

Business Application Programming Interface (BAPI) is a precisely defined interface providing access to processes and data in business application systems such as R/3. BAPIs are defined as API methods of SAP business object types.  A BAPI is implemented as a function module, that is stored and described in the Function Builder.

BAPI is basically a RFC enabled function module. The difference between RFC enabled function module and BAPI is business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. In this case you only specify the business object and its method from external system. In BAPI there is no direct system call, while RFC are direct system call. Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types. In short BAPI is a RFC enabled function module on the wrapper of Business object. 
Properties of BAPI:
1.       Naming convention BAPI_<business object name>_<method name>
2.       BAPI is always remote enabled function module
3.       It contains neither user dialogs nor messages
4.       BAPI raise no exception
5.       Return parameter which is the export parameter is mandatory for BAPI to report the errors because BAPI doesn't return any sy-subrc value.
 
We have a lot of standard BAPIs into the SAP system. Some of those are as follows.
GetList – Returns a list of available objects which meet the specified selection criteria.
GetDetail – Returns the detailed information for an object. Here the complete key must be specified.
Create, Change, Delete, Cancel – It allows us to do that.
AddItem, RemoveItem – It allows us to do that.
 
It is important to read this documentation thoroughly because BAPIs vary widely in their structure and behavior, and they can sometimes work in unexpected ways or fail with cryptic error messages if their requirements are not met.
 
     BAPIs are implemented as function modules, they do not fit naturally in the ABAP object-oriented programming (OOP) paradigm of classes, methods and interfaces. Nonetheless, they are usually implemented in an object-oriented way, as they are interfaces to SAP business objects. It is often preferable to wrap BAPI calls in data access objects (DAOs), which are classes that encapsulate the calls to the BAPIs.