Bapi jco[1]
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Bapi jco[1]

on

  • 1,436 views

BAPI Creation Step By Step and connection with external system

BAPI Creation Step By Step and connection with external system

Statistics

Views

Total Views
1,436
Views on SlideShare
1,168
Embed Views
268

Actions

Likes
1
Downloads
107
Comments
0

4 Embeds 268

http://sapabapmaterials4u.blogspot.in 256
http://www.docshut.com 9
https://www.blogger.com 2
http://localhost 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Bapi jco[1] Presentation Transcript

  • 1. BAPIBusiness Application Programming Interface Compiled by Y R Nagesh 1
  • 2. What is BAPI A Business Application Programming Interface is aprecisely defined interface providing access processand data in Business Applications Systems Such asSAP R/3 Compiled by Y R Nagesh 2
  • 3. Benefits of BAPICan be used in diverse languages / Development Environments(ABAP, Visual Basic, Java, C++, etc.)Can be called from diverse platforms (COM, CORBA, Unix)Reduced development costReduced maintenance cost“Best-of-both-worlds” approach Rich functionality of the R/3 system User-specific front-ends Compiled by Y R Nagesh 3
  • 4. Where BAPIs can be used Compiled by Y R Nagesh 4
  • 5. Return Code InformationUsually a structure, sometimes a tableData dictionary structures used BAPIRETURN BAPIRETURN1 BAPIRET1 BAPIRET2 Compiled by Y R Nagesh 5
  • 6. BAPI Return Structure Type Message type blank or "S"=Success "E"=Error "W"=Warning "I"=Information "A"=AbortMessage Message textLog_No Application Log NumberLog_Msg_No Application Log Message Serial NumberMessage_V1 - V4 Message variables Compiled by Y R Nagesh 6
  • 7. SAP transactionsBAPI Business Object Browser (BAPIs only)SWO1 Business Object Builder (all objects)SWO2 Business Object Browser (all objects)SE11 Data DictionarySE37 Function Builder Compiled by Y R Nagesh 7
  • 8. JCO OverviewHigh-performance JNI-based middlewareSupport R/3 3.1H and higher.Supports inbound and outbound calls.Supports client pooling.Supports desktop and web/application server applications.Multi-platformComplete and correct code page handlingEasy to install and deploy Compiled by Y R Nagesh 8
  • 9. Installation and DeploymentRequired files in WINNTsystem32: 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 Compiled by Y R Nagesh 9
  • 10. BAPI step by step procedureSTEP 1 - Define Structure For The BAPISTEP 2 - Write Function ModuleSTEP 3 - Create the API Method Using The BAPI WIZARDSTEP 4 – Final Steps Compiled by Y R Nagesh 10
  • 11. About the ExampleAbout the Example: Front End : Java Servlets (Web Application) Web Server : Apache TomcatThe Servlet takes Vendor number and passes it to the BAPI whichin turn fetches the Vendor information from the LFA1 table andreturns it in BAPIRET2 format to the servlet, the servlet fetches thedata from return structure and displays it. Compiled by Y R Nagesh 11
  • 12. 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 TCODE : SE11 then Data type -> Structure Define the structure Name : Ex: ZVENDImportant note: You will have to define a structure forevery parameter in the BAPI. You cannot use the samestructures used in existing applications because BAPIstructures are frozen when BAPIs are released and thenthere are restrictions on changing them. Compiled by Y R Nagesh 12
  • 13. Creating a Structure Enter the Structure name Click on Create Compiled by Y R Nagesh Button 13
  • 14. Creating a Structure Select Structure Click onCheck Button Compiled by Y R Nagesh 14
  • 15. Creating a Structure Activate the Structure Compiled by Y R Nagesh 15
  • 16. Step 2 : Write Function ModuleEach BAPI must have its own function group.Under the attributes tab remember to select Processing Type RemoteEnabled module, otherwise the function module cannot be invoked viaRFC and used as a BAPIImport/Export parameters can only be BY VALUE for an RFC enabledfunction module Compiled by Y R Nagesh 16
  • 17. Creating Function group Compiled by Y R Nagesh 17
  • 18. Creating Function group Compiled by Y R Nagesh 18
  • 19. Creating Function module Click on Create Click on Save Compiled by Y R Nagesh 19
  • 20. Creating Function moduleMake the functionRemote Enabled Compiled by Y R Nagesh 20
  • 21. Creating Function moduleImport Parameters Check “ Pass Value” Compiled by Y R Nagesh 21
  • 22. Creating Function moduleTables Compiled by Y R Nagesh 22
  • 23. Creating Function moduleSource Code Compiled by Y R Nagesh 23
  • 24. Creating Function moduleActivate Function Module Activate Compiled by Y R Nagesh 24
  • 25. Releasing Function moduleRelease the Function Module Compiled by Y R Nagesh 25
  • 26. Step 2 : Create the API Method Using The BAPI WIZARD BAPI wizard is used to expose the remote function module as a BAPI Wizard will generate some additional code, so the function module is a valid method of the BOR. This allows the BAPI to be called as a workflow method in addition to be called by an outside program. Each function module corresponds to a method in the BORGo to the Business Object Builder SWO1. You can either create the new Object type as a subtype of an existing businessobject or create a new business object from scratch.. Compiled by Y R Nagesh 26
  • 27. Create new BAPI Object USE TCODE SWO1 Supertype not required as we are creating a new Object * for Cross Apps Compiled by Y R Nagesh 27
  • 28. Create new BAPI ObjectNote that when you create the business object a standardinterface, an attribute ObjectType and the methodsExistenceCheck and Display are automatically generated.These cannot be changed ! Compiled by Y R Nagesh 28
  • 29. Adding API method Compiled by Y R Nagesh 29
  • 30. Adding API methodClickhere Compiled by Y R Nagesh 30
  • 31. Adding API method Compiled by Y R Nagesh 31
  • 32. Adding API method Click YesAPI method added Compiled by Y R Nagesh 32
  • 33. Implementing BAPI ObjectSelect the BAPI object Compiled by Y R Nagesh 33
  • 34. Implementing BAPI ObjectChange release status To implemented Compiled by Y R Nagesh 34
  • 35. Releasing BAPI ObjectChange release status To released Compiled by Y R Nagesh 35
  • 36. Implementing API MethodSelect the API Method Compiled by Y R Nagesh 36
  • 37. Implementing API MethodChange release status To implemented Compiled by Y R Nagesh 37
  • 38. Releasing API MethodChange release status To released Compiled by Y R Nagesh 38
  • 39. Generating API Method Click on Generate Button Compiled by Y R Nagesh 39
  • 40. Configuring Apache Tomcat Directory StructureJakarta-tomcat-4.1.31 Webapps <User Folder> (Vendor) WEB-INF classes lib Web.xml Index.html Compiled by Y R Nagesh 40
  • 41. Configuring Apache Tomcat classes This folder contains all the class files created for successful execution of the servlet. lib This folder contains all the library files required i.e sapjco.jar servlet.jarNote: While compiling the java code make sure that the Classpath is set to the above to .jar files Compiled by Y R Nagesh 41
  • 42. Configuring Apache Tomcat Web.xml<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee“ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd“ version="2.4"> <servlet> <servlet-name>Some internal name</servlet-name> <servlet-class>display_vend</servlet-class> </servlet> <servlet-mapping> Servlet name <servlet-name>Some internal name</servlet-name> <url-pattern>/NameSeenByUser.do</url-pattern> </servlet-mapping></web-app> Compiled by Y R Nagesh 42
  • 43. Servlet Programimport statements required import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import com.sap.mw.jco.*; Compiled by Y R Nagesh 43
  • 44. Servlet Programpublic 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; Unique name for connection pool each String SID = "R"+num; time connection is String vendno = req.getParameter("vendno"); established random number is generated in IRepository repository; // The repository we will be using the index.html i.e starting page and try { value is passed to servlet // Add a connection pool to the specified system JCO.addClientPool(SID, 100, "800", "hari", "sapnjoy", "EN", "sapides", "00” ); // Alias for this pool , Max. number of connections , SAP client , userid // password , language , host name Compiled by Y R Nagesh 44
  • 45. Servlet Program repository = JCO.createRepository("MYRepository", SID); // Create a new repository// Get a function template from the repositoryIFunctionTemplate ftemplate = repository.getFunctionTemplate("ZVENDFUN");// Create a function from the templateJCO.Function function = new JCO.Function(ftemplate);JCO.Client client = JCO.getClient(SID); // Get a client from the poolJCO.ParameterList input = function.getImportParameterList(); // Fill in input parametersinput.setValue(vendno, "LIFNR" );client.execute(function); // Call the remote systemJCO.Structure ret = function.getExportParameterList().getStructure("RETURN");pw = res.getWriter();pw.println("<html><body bgcolor=#eeeff8><center><hr><h1>Customer Details</h1><hr>");// Get table containing the dataJCO.Table vend = function.getTableParameterList().getTable("ITAB"); Compiled by Y R Nagesh 45
  • 46. Servlet Programfor (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") ; // Fetching data from SAP database and storing in local variables Compiled by Y R Nagesh 46
  • 47. Servlet Programpw.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> </td><td><B>City</B></td><td>"+city+"</td></tr>" + "<tr><td> </td><td><B>District</B></td><td>"+district+"</td></tr>"+ "<tr><td> </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=submitvalue=Back></form></center></body></html>"); }}catch (Exception E) { System.out.println(E); } } } Compiled by Y R Nagesh 47
  • 48. 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
  • 49. Output Compiled by Y R Nagesh 49
  • 50. Output Compiled by Y R Nagesh 50