Business Application Programming Interface: Compiled by Y R Nagesh 1
Business Application Programming Interface: Compiled by Y R Nagesh 1
Compiled by Y R Nagesh
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
Compiled by Y R Nagesh
Benefits of BAPI
Can be used in diverse languages / 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 functionality of the R/3 system User-specific front-ends
Compiled by Y R Nagesh 3
Compiled by Y R Nagesh
Compiled by Y R Nagesh
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
Compiled by Y R Nagesh
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. Multi-platform Complete and correct code page handling Easy to install and deploy
Compiled by Y R Nagesh
Compiled by Y R Nagesh
Compiled by Y R Nagesh
10
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.
Compiled by Y R Nagesh
11
Creating a Structure
Compiled by Y R Nagesh
Creating a Structure
Compiled by Y R Nagesh
14
Creating a Structure
Activate the Structure
Compiled by Y R Nagesh
15
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
Compiled by Y R Nagesh
16
Compiled by Y R Nagesh
17
Compiled by Y R Nagesh
18
Click on Create
Click on Save
Compiled by Y R Nagesh
19
Compiled by Y R Nagesh
20
Compiled by Y R Nagesh
21
Compiled by Y R Nagesh
22
Compiled by Y R Nagesh
23
Activate
Compiled by Y R Nagesh
24
Compiled by Y R Nagesh
25
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..
Compiled by Y R Nagesh
26
Compiled by Y R Nagesh
28
Compiled by Y R Nagesh
29
Click here
Compiled by Y R Nagesh 30
Compiled by Y R Nagesh
31
Compiled by Y R Nagesh
32
Compiled by Y R Nagesh
33
Compiled by Y R Nagesh
34
Compiled by Y R Nagesh
35
Compiled by Y R Nagesh
36
Compiled by Y R Nagesh
37
Compiled by Y R Nagesh
38
Compiled by Y R Nagesh
39
lib
This folder contains all the library files required i.e sapjco.jar servlet.jar
Note: While compiling the java code make sure that the Classpath is set to the above to .jar files
Compiled by Y R Nagesh 41
Web.xml
Servlet name
Servlet Program
import statements required import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import com.sap.mw.jco.*;
Compiled by Y R Nagesh
43
Servlet Program
public class display_vend extends HttpServlet { PrintWriter pw; public void doPost(HttpServletRequest req, HttpServletResponse res) { int num = Integer.parseInt(req.getParameter("rand")); String no,name,city,district,po,tele,fax; String SID = "R"+num; String vendno = req.getParameter("vendno"); IRepository repository; // The repository we will be using try {
Unique name for connection pool each time connection is established random number is generated in the index.html i.e starting page and value is passed to servlet
// Alias for this pool , Max. number of connections , SAP client , userid // password , language , host name
Compiled by Y R Nagesh 44
Servlet Program
repository = JCO.createRepository("MYRepository", SID); // Create a new repository
Servlet Program
for (int i = 0; i < vend.getNumRows(); i++) { vend.setRow(i); no = vend.getString("LIFNR"); name = vend.getString("NAME1"); city = vend.getString("ORT01") ; district = vend.getString("ORT02") ; po = vend.getString("PFACH") ; tele = vend.getString("TELF1") ; fax = vend.getString("TELFX") ;
Compiled by Y R Nagesh
46
Servlet Program
pw.println("<table border=1><tr><td><B>Vendor Number</B></td><td>"+no+ "</td></tr><tr><td>" + "<B>Customer Name</B></td><td>"+name+ "</td></tr><tr><td>" + "<B>Customer Address</B></td><td></tr>"+ "<tr><td> "<tr><td> "<tr><td> </td><td><B>City</B></td><td>"+city+"</td></tr>" + </td><td><B>District</B></td><td>"+district+"</td></tr>"+ </td><td><B>PO Box</B></td><td>"+po+"</td></tr>"+
"<tr><td><B>Telephone</B></td><td>"+tele+"</td></tr>"+ "<tr><td><B>TeleFax</B></td><td>"+fax+"</td></tr></table>" ); pw.println("<form name=form1 action='index.html' method=get><input type=submit value='Back'></form></center></body></html>"); }} catch (Exception E) { System.out.println(E); } } } Compiled by Y R Nagesh 47
Index.html
<html> <head><script language="JavaScript"> function randomnumber() { var r=Math.floor(Math.random()*1111) if (r!=0) document.form1.rand.value=r; } </script> </head> <body bgcolor=#eeeff8 onLoad="javascript:randomnumber();"> <center><hr><h1>Enter the Vendor Number</h1><hr> </center><form name=form1 action="NameSeenByUser.do" method=post> <center><input type=text name=vendno> <input type=submit value="Submit"> <input type=hidden name="rand"></center> </form></body></html> Compiled by Y R Nagesh 48
Output
Compiled by Y R Nagesh
49
Output
Compiled by Y R Nagesh
50