Business Application Programming Interface
What is BAPI
A Business Application Programming Interface is a precisely defined interface providing access process and data in Business Applications Systems Such as SAP R/3
Benefits of BAPI
■ Can be used in diverse language/Development Environments (ABAP, Visual Basic, JAVA, C++, etc.)
■ Can be called from diverse platforms (COM, CORBA, Unix)
■ Reduced development cost
■ Reduced maintenance cost
■ “Best-of-both-worlds” approach
■ Rich functionally of the R/3 system
■ User-specific front-ends
Return Code Information
■ Usually a Structure, sometimes a table
■ Data dictionary structures used
◆ BAPIRETURN
◆ BAPIRETURN1
◆ BAPIRET1
◆ BAPIRET2
BAPI Return Structure
■ Type Message type
◆ blank or “S”=Success
◆ “E”=Error
◆ “W”=Warning
◆ “I”=Information
◆ “A”=Abort
■ Message Message text
■ Log_No Application Log Number
■ Log_Msg_No Application Log Message Serial Number
■ Message_V1-V4 Message variables
SAP transactions
■ BAPI Business Object Browser (BAPIS only)
■ SWO1 Business Object Builder (All objects)
■ SWO2 Business Object Browser (all objects)
■ SE11 Data Dictionary
■ SE37 Function Builder
JCO Overview
■ High-performance JNI-based middleware
■ Support R/3 3.1H and higher.
■ Supports inbound and outbound calls.
■ Supports client pooling.
■ Supports desktop and web/application server applications.
■ Muti-platform
■ Complete and correct code page handing
■ Easy to install and deploy
Installation and Deployment
■ Required files in /WINNT/system32:
◆ librfc32.dll (at least 46D, build 263)
◆ jRFC11.dll (JDK 1.1)
◆ jRFC12.dll (JDK 1.2 AND 1.3)
■ Required files in JAVA class path:
◆ jCO.jar
BAPI step by step procedure
STEP1 – Define Structure For The BAPI
STEP2 – Write Function Module
STEP3 – Create the API Method Using The BAPI WIZARD
STEP4 – Final Steps
About the Example
About the Example :
Front End : JAVA Servlets (Web Application)
Web Server : Apache Tomcat
The Servlet takes Vendor number and passes it to the BAPI which in turn fetches the Vendor information from the LFA1 table and returns it in BAPIRET2 format to the servlet, the servlet fetches the data from return structure and displays it.
Step 1: Define a Structure for BAPI
In this step structures for the parameters and tables of the function module used for the BAPI are defined.
USE T CODE : SE11 then Data type -> Structure
Define the structure Name : Ex: ZVEND
Important note:
You will have to define a structure for every parameter in the BAPI. You cannot use the same structures used in existing applications because BAPI structures are frozen when BAPIS are released and then there are restrictions on changing them.
STEP 2 - Write Function Module
- Each BAPI must have its own function group.
- Under the attributes tab remember to select Processing Type Remote Enabled module, otherwise the function module cannot be invoked via RFC and used as a BAPI
- Import/Export parameters can only be BY VALUE for an RFC enabled function module
- We are only creating one BAPI in this example, but you can create related BAPIs in the same function pool, so they will be able to share global data.
STEP 3 - Create the API Method Using the BAPI Wizard
The BAPI wizard is used to expose the remote function module as a BAPI. The wizard will generate some additional code, so the function module is a valid method of the BOR (Business Object Repository). This allows the BAPI to be called as a workflow method in addition to be called by an outside program.
Note: Each function module corresponds to a method in the BOR
Go to the Business Object Builder SWO1.
You can either create the new Object type as a subtype of an existing business object or create a new business object from scratch. In this example it would be obvious to create the Object type as a subtype of BUS2005 Production order. However, to illustrate how to create a new Object type from scratch, we will do this.
In the Object/Interface type field write the name of the new Business Object: ZORDERSTAT. Press enter and fill in the additional fields necessary to create the object type.
Supertype: Not relevant because we are creating our object from scratch
Program. This is the name of the program where the wizard generates code for the Object type, NOT the function module we created earlier. The program name must not be the name of an existing program.
Press enter and create the new business object. Note that when you create the business object a standard interface, an attribute Object Type and the methods Existence Check and Display are automatically generated. These cannot be changed !