You are on page 1of 29

BAPI Presentation

Chaitanya Latha.T Lakshmi Durga.P

What is BAPI ?
API method of a business object(BO).

Implemented as an RFC

Architecture

Business Object
Provides Object Oriented view of R/3

business functionality.

Encapsulates R/3 data and business processes, by hiding the structure and implementation.

Object types and Object instance


Each BO belongs to specific class based on nature and characteristics. These Object classes are called Object Types. Each individual SAP business object is a representation, or instance, of its object type

SAP BO
Object

Type Key fields Attributes Methods Events Interfaces

Object Type
The object type describes the features common to all instances of that object type. This includes information such as the unique name of the object type.

Key Fields
To access a specific instance of the object type
Ex: SalesDocument number of sales order.

Can Conists of several key fields. All the key fields should be from same table. Must be used as parameters in instance dependent BAPIs.

Attributes
Specific property of an object. They can be from different tables. Ex: SalesDocumentType of salesorder.
DataBase

Attributes Virtual Attributes(Macros) Object Virtual Attributes Multiline Virtual Attributes

Methods

An operation that is performed on a business object either to access or process business data.

Adding a method
With remote enabled With out remote enabled

Events
Signals to notify that the status change of an business object.

Used only in workflow.

Interface
Group of related methods associated with an object type.

Documentation
Describes the functionality of methods. Possible return messages.

Business Object Repository


The Business Object Repository (BOR) is the repository of Business Objects in the R/3 System. It contains SAP Business Objects and SAP Interface types methods and their attributes
Transaction Code: /bapi

BOR use
Provides an object oriented view of R/3

System data and processes. R/3 application functions are accessed using methods (BAPIs) of SAP Business Objects. Implementation information is encapsulated; only the interface functionality of the method is visible to the user. Arranges the various interfaces in accordance with the component hierarchy, enabling functions to be searched and retrieved quickly and simply. Manages BAPIs in release updates.

Relation between Objective types


Inheritance allowing common attributes and methods to be passed automatically from supertypes to subtypes Composition "Is part of" relationship between object types Interface Implementation - expressing which object types support an interface. Association an attribute referencing another object type as an object reference.

RFC Implementation
Function Module which is a remote enabled one. Parameters

Import Export Table(Import/Export)

Exceptions

Programming Guidelines
The following steps are to be done for an RFC underling a BAPI. BAPIRETURN structure is must as an export parameter To be processed without returning any screen dialogs to the calling application Should not contain Following statements are not allowed. Call Transaction Submit Report Submit Report and Return

Accessing BAPIs
Object-Oriented Access Function Oriented Access
R/3 Server
BAPI BAPI Business Object: Sales Order BAPI BAPI

BAPI BAPI

Function module (RFC capable) Function module (RFC capable) Function module (RFC capable)

Business Object Repository

Function Builder

Object-oriented access

RFC access

Object-Oriented Access to BAPIs


Development Tools/MiddleWare

BAPI ActiveX Control BAPI C++ Class library BAPI Java Class library R/3 Dcom Component Connector

Programming Environments

Delphi connect for SAP Access Builder for SAP R/3 Visual Studio

Object Oriented
Set boOrder = oBAPICtrl.GetSAPObject("SalesOrder") Set oOrderHeader = oBAPICtrl.DimAs(boOrder, _ "CreateFromDat1", "OrderHeaderIn") Set otabItems = oBAPICtrl.DimAs(boOrder, _ "CreateFromDat1", "OrderItemsIn") Set otabPartners = oBAPICtrl.DimAs(boOrder, _ "CreateFromDat1", "OrderPartners") Calling the BAPI boOrder.CreateFromDat1 OrderHeaderIn:=oOrderHeader, OrderPartners:=otabPartners, OrderItemsIn:=otabItems, Return:=oReturn

Function Oriented
Calling RFC theModule.setFunctionName("ZEMP_GETLIST"); Module.callReceive(); setting parameters dept = facMan.getSimpleFactory().createSimple( new SimpleInfo(null, IFieldInfo.RFCTYPE_CHAR,10, 0),"DEPT" ); deptTable.setParameterName("emp_table"); Import/Export theModule.addImportParam(dept); theModule.addTableParam(deptTable);

Naming Conventions
Business Object: BUS0001 where 0001 is an active function group. Function Module: BAPI_<object name>_<methodName> Method Name: max 30 chars. Should start with capital letter. GetDetail Reference fields: Structures. Should start with BAPI

Standard BAPIs
They provide basic functions and can be used for most SAP BO. The Object methods with BAPIs can differentiate between Instance Methods and Class Methods. BAPIs for Reading Data : GetList Method type Class GetDetail Instance GetStatus Instance ExistenceCheck Instance BAPIs for Creating or Changing Data : Create or CreateFromData Class Change Instance Delete and Undelete Instance BAPIs for Replicating BO Instances : Replicate and SaveReplica Class

ServiceBAPIs
They provide basic help functions.

HelpValues.GetList (F4 help) BapiService.FieldHelpGetDocu BapiService.InterfaceGetDocu BapiService.TransactionCommit BapiService.Rollback BapiService.DataConversionInt2Ext1 BapiService.DataConversionEnt2Int1

Customer Modifications to BAPIs


Creating a BAPI for an existing Business Object. Copy the function module and make the required changes Creating a BAPI for new Business Object. Inherit the object and override the method

Enhancements
It is carried out ensuring the syntax and downward compatibility. Compatible interface enhancements. New Optional parameters New optional fields to structure Incompatible interface enchancements Changes to the field length Changes to the field type Inserting a field within a structure Deleting parameters and fields Adding new mandatory fields or mandatory parameters

CheckList
Have you identified the SAP Business Object involved? Is the BAPI assigned to the appropriate SAP Business Object? Have you identified the key fields and attributes of this Business Object? Have you defined the function module interface using only EXPORTING, IMPORTING and TABLES parameters?

CheckList
Have you defined the formats in which the values must be transferred in the function module interface? Have you included a Return parameter? Are you using the Dictionary structure BAPIRETURN1 or BAPIRET2 for the Return parameter (as of Release 4.0)? Did you create the function group, if required? Did you create the function module? Did you create the documentation for the BAPI in the Function Builder? Did you use the program to map between internal and external data formats?

You might also like