Business Application Programming Interface (BAPI)
Contributed by
Sana Shaikh
Under the guidance of TagSkills
Business Application Programming Interface(BAPI) are standardized
programming interfaces (methods) enabling external applications to access
business processes and data in the R/3 System. BAPIs (Business Application
Programming Interface) are specific methods for SAP business objects, which
are stored in the Business Object Repository (BOR) of the SAP system and are
used for carrying out particular business tasks.
They provide stable and standardized methods to achieve seamless
integration between the R/3 System and external applications, legacy systems
and add-ons.
BAPIs are defined in the BOR(Business object repository) as methods of SAP
business object types that carry out specific business functions. They are
implemented as RFC-enabled function modules and are created in the
Function Builder of the ABAP Workbench. The SAP business objects stored in
the Business Object Repository (BOR) encapsulate their data and processes.
External access to the data and processes is only possible by means of specific
methods - BAPIs (Business Application Program Interfaces
Some BAPIs and methods provide basic functions and can be used for most
SAP Business Objects.These are called STANDARDIZED BAPI’s.
Example
The functions that are implemented in the SAP business CostCenter object type
include, for example, listing all the available cost centers. The business object
type CostCenter provides the BAPI GetList() for this purpose.
6360959192 www.tagskills.com support@tagskills.com
List of Standardized BAPIs:
BAPIs for Reading Data – GetList() , GetDetail() , GetStatus() ,
ExistenceCheck()
BAPIs for Creating or Changing Data- Create() ,Change(),Delete() and
Undelete() ,
BAPIs for Mass Processing -ChangeMultiple(), CreateMultiple(),
DeleteMultiple().
GetList ( ) With the BAPI GetList you can select a range of object key values,
for example, company codes and material numbers.
The BAPI GetList() is a class method.
GetDetail() With the BAPI GetDetail() the details of an instance of a business
object type are retrieved and returned to the calling program. The instance is
identified via its key. The BAPI GetDetail() is an instance method. BAPIs that
can create, change or delete instances of a business object type
The following BAPIs of the same object type have to be programmed so that
they can be called several times within one transaction. For example, if, after
sales order 1 has been created, a second sales order 2 is created in the same
transaction, the second BAPI call must not affect the consistency of the sales
order 2. After completing the transaction with a COMMIT WORK, both the
orders are saved consistently in the database.
Create( ) and CreateFromData! ( )
The BAPIs Create() and CreateFromData() create an instance of an SAP
business object type, for example, a purchase order. These BAPIs are class
methods.
Change( )
The BAPI Change() changes an existing instance of an SAP business object
type, for example, a purchase order. The BAPI Change () is an instance method.
Delete( ) and Undelete( ) The BAPI Delete() deletes an instance of an SAP
business object type from the database or sets a deletion flag.
6360959192 www.tagskills.com support@tagskills.com
The BAPI Undelete() removes a deletion flag. These BAPIs are instance
methods.
Cancel ( ) Unlike the BAPI Delete(), the BAPI Cancel() cancels an instance of a
business object type. The instance to be cancelled remains in the database and
an additional instance is created and this is the one that is actually canceled. The
Cancel() BAPI is an instance method.
Add<subobject> ( ) and Remove<subobject> ( ) The BAPI Add<subobject>
adds a subobject to an existing object inst! ance and the BAPI and
Remove<subobject> removes a subobject from an object instance. These BAPIs
are instance methods.
How to create a BAPI
Step 1) Go to transaction swo1 (Tools->Business Framework -> BAPI
Development ->Business Object builder ) .
Select the business object, according to the functional requirement for which the
BAPI is being created.
Step 2) Open the business object in change mode. Then Select Utilities ->API
Methods ->Add method. Then enter the name of the function module and select
Continue.
Step 3) In the next dialog box, following information needs to be specified :
Method : Suggest an appropriate name for the method,
Texts : Enter description for the BAPI,
Radio buttons : Dialog, Synchronous, Instance-independent . BAPI ‘s are
usually implemented synchronously.
Step 4) After the program has been generated and executed, check the program
in the method just created. Thus , a BAPI is created.
Testing the BAPI
You can test the BAPI by Testing the individual method of the Business Object
in the Business Object Builder. ( or one can use the transaction ‘SWUD’ to test
the method ) .
6360959192 www.tagskills.com support@tagskills.com
Releasing and freezing the BAPI
To release the BAPI , first release the function module ( using transaction
se37 ) .
Set the status of the method to ‘released’ in the Business Object Builder (
using transaction SWo1 – Edit-> change status-> released. )
You can also use the BAPI Explorer (Transaction code BAPI) for 360′ view on
BAPI
BAPI (Business Application Programming Interface) is a set of interfaces to
object-oriented programming methods that enable a programmer to integrate
third-party software into the proprietary R/3 product from SAP. For specific
business tasks such as uploading transactional data, BAPIs are implemented and
stored in the R/3 system as remote function call (RFC) modules.
A BAPI is remotely enabled function module ie it can be invoked from remote
programs like standalone JAVA programs, web interface etc..
You can make your function module remotely enabled in attributes of Function
module .
In the SAP system, BAPIs are stored as RFC-capable function modules in the
ABAP Workbench Function Builder. BAPIs have standard business interfaces
that enable external applications (with the help of SAP business objects) to
access SAP processes, functions and data.
Client programs that use BAPIs to access SAP business objects can be part of
the same SAP system, part of an external system (for example, a .Net
application), part of an HTTP Gateway, or part of another SAP system.
If you want to use a BAPI to trigger a business process in another system, you
usually use the synchronous communication methods RFC, because in most
cases, you want the data to be returned to the sending system.
For asynchronous communication using BAPIs, ALE is used, with additional
IDoc interfaces being generated for the BAPIs.
BAPI (Business Application Programming Interface) is a standard SAP
application interface that helps to integrate non-SAP applications with the SAP
business process and enables providing data entry into the SAP system.
6360959192 www.tagskills.com support@tagskills.com
BAPI is a standard programming interface that enables external access to the
business processes in the SAP system.
It is configured and stored as an RFC (Remote Function Call) enabled
module in the functional builder of the SAP ABAP workbench and it
helps to perform the automatic tests without using any UI (user
Interface)
SAP BAPI is a remotely enabled system for remote programs like web
interfaces, programs, and mobile apps. Business Application
Programming Interface consists set of input & output parameters and
a set of tables.
The code in the BAPI takes input parameters and processes the
queries, and operations, and sends back the data. BAPIs in the SAP
systems are implemented as functional modules and every module with
BAPIs that supports the RFC protocol.
BAPIs are used for reading the queries and creating, deleting, and
editing operations.
BAPI explorer helps to access the collections of BAPIs in the system
which are grouped in Hierarchical and Alphabetical.
Each Business Application Programming Interface explorer is
provided with options like Details, Documentation, Tools, and Project.
The BAPIs in the SAP Systems are currently implemented as function modules,
which are created and managed in the Function Builder. Each function module
underlying a BAPI:
Supports the Remote Function Call (RFC) protocol
Has been assigned as a method to a SAP business object type in the
Business Object Repository
Is processed without returning any screen dialogs to the calling
application Integration
Integration
The graphic below shows the relationship between an SAP business object type,
its associated BAPIs and its function modules.
6360959192 www.tagskills.com support@tagskills.com
What the difference between BDC and BAPI? What the exact situation where
we can use BDC and BAPI?
BDC is the good old method of moving legacy data to SAP.
BAPI is the new enhanced Application Interface through which data can be
uploaded into SAP System.
BDC is transaction oriented. Meaning, the data is uploaded into SAP through
standard transactions. All checks, validations,exits that are applicable to the
transaction are active while loading data into SAP.
Simply saying, BDC is continuous running of transaction repeatedly without
human intervention, data being picked from text file for each run. It is just a
bundling of multiple executions of the same transaction and execute at once like a
macro.
Whereas BAPI is an interfacing method, through which SAP data can be processed
from within SAP or from other non-SAP applications. BAPI can be termed as
SAP transaction without dialog. All the screens of particular transaction is
converted in the form of a Code Module.
We can establish on-line interface with SAP data from non-SAP applications
through BAPI's if they are enabled for Remote Access.
Generally BDC is preferred if the data from the legacy system is moved to SAP
single time. For example, at the time of Go-Live the data required for SAP is
either downloaded from other software or manually prepared in excel sheets and
uploaded into SAP at once. After that data or SAP has nothing to do with other
software.
BAPI's are preferred, if data exchange is online or continuous between SAP
transactions or SAP and non-SAP applications. BAPI's are preferred in view of
performance also. Data loading through BAPI's are more robust and faster
comparatively, if they are called correctly.
6360959192 www.tagskills.com support@tagskills.com
What is the main difference between BAPI and BDC?
BAPI BDC
BAPI is used only when it is available for BDC can be used for any
the particular transaction like Delivery transaction which have screen
Sales order. and fields.
BAPI has directly updated the
database. So BAPI can't handle all the
BDC run through the screen
flow logic checking and enhancement put
flow.
by programmer to facilitate the user
requirement.
BAPI is faster BDC is slower.
BAPI never cause to terminate the
Sometimes BDC open group BDC
program whenever error is in BAPI it is
insert BDC close group may
simply written those errors through
cause to terminate the program
written parameters
In BDC we provide the authority
to validate the user
BAPI performs their own Authorization
Authority—check <obj name>id
checks to validate the user
<name> active
<value>
In BDC the flat file fields are
In BAPI the flat file fields are varying
fixed.
6360959192 www.tagskills.com support@tagskills.com
BAPI BDC
Whenever the version is changed
Whenever the version is changed we no
we sometime need to change
need to change the code
the code
Good for uploading mass data
Good for connecting SAP system to others.
internally.
Objective :
Uploading single record in database table Using BAPI.
steps :
1: Search for BAPI: So BAPI_BANK_CREATE is the function module that can
help to upload the data.
6360959192 www.tagskills.com support@tagskills.com
2: As only single record is to be added we can assign values in work area.
Pass that through function module , then COMMIT using function module
BAPI_TRANSACTION_COMMIT.
OUTPUT:
6360959192 www.tagskills.com support@tagskills.com
Objective :
Uploading Bulk of Data from Excel sheet to SAP system Using BAPI.
steps :
1: Search for BAPI: So BAPI_BANK_CREATE is the function module that can
help to upload the data.
2: As we want to upload bulk of data we will create internal table LT_BANK.
Pass that through function module , then COMMIT using function module
BAPI_TRANSACTION_COMMIT.
6360959192 www.tagskills.com support@tagskills.com
3. for searching we need f4 help option and uploading the excel file we need
to use the function module F4_FILENAME and
TEXT_CONVERT_XLS_TO_SAP.
4. using BAPI_BANK_CREATE we are uploading whole mass data then
performing COMMIT to save it
6360959192 www.tagskills.com support@tagskills.com
4. BAPI can also handle the error using FORMAT_MESSAGE, using it
displaying all possible error in output.
6360959192 www.tagskills.com support@tagskills.com
Excel file
6360959192 www.tagskills.com support@tagskills.com
Selection screen- Upload Excel file
Output : Bulk of Data Inserted for Excel Sheet.
6360959192 www.tagskills.com support@tagskills.com
TagSkills:
Disclaimer –
© Copyright TagSkills. The copyright in this work is vested in TagSkills.
Please note and abide by copyright laws. This presentation is for educational
purposes only, all logos, photos, and information, etc used in this
Presentation is the property of TagSkills. SAP is a registered trademark of
SAP AG in Germany and many other countries. We are NOT
ASSOCIATED www.tagskills.com © Copyright TagSkills. The copyright
in this work is vested in TagSkills. Please note and abide by copyright laws.
This presentation is for educational purposes only, all logos, photos, and
information, etc used in this Presentation is the property of TagSkills. SAP
is a registered trademark of SAP AG in Germany and many other countries.
We are NOT ASSOCIATED with SAP.
6360959192 www.tagskills.com support@tagskills.com