Professional Documents
Culture Documents
BAPIs
Contents:
The role of BAPIs
BAPI Transaction Model
SAP AG 1999
SAP AG 1999
Good Bye
Enhancements
and Modifications
1 12 1 Course Overview
BAPIs
1
New Concepts
0
9 1
2 3
News in ABAP
ABAP Objects Workbench
ABAP Language
4
Graphical Query
8
Tools
7 5
Screen Objects 6 Logical Databases
ABAP Dictionary
SAP AG 1999
BAPI
SAP AG 1999
A BAPI functions as a "gateway" to the R/3 System, in other words, the R/3 System uses it to
provide access to business data and processes.
An object in the BOR can have many methods, one or more of which are implemented as BAPIs.
BAPIs can have various functions
Generating an object
Querying attributes of an object
Changing attributes of an object
...
R /3 s a te llite s y s te m s /
d is tr ib u te d s c e n a r io s (A L E )
B u s in e s s
W o r k flo w
V is u a lB a s ic /J A V A ...
In te r n e t/
In tr a n e t
B u s in e s s B u s in e s s
C om ponent C o m p o n e Bn t
R /3 c o m p o n e n t
fo r m a tio n B u s in e s s C u s to m e r o r p a rtn e r
C om ponent
d e v e lo p m e n ts
SAP AG 1999
Object-oriented
Access to methods from BOR objects
Stable interface
A BAPI interface is "frozen"
Release function module for customer
Link data elements to the interface parameters of the FM
Can be used internally and externally
BAPIs can be used within R/3 and externally
But: BAPIs do not contain a presentation layer
Results are visualized externally by the individual caller
SAP AG 1999
Methods:
FlightBooking.GetList
FlightBooking.GetDetail
FlightBooking.CreateFromData
FlightBooking.Cancel
AirlineCarrier
ConnectionNumber
DateOfFlight
BookingNumber
SAP AG 1999
An example business object from the training course data model is called FlightBooking. It contains
a booking. Each booking is uniquely identifiable from its key information: AirlineCarrier ,
ConnectionNumber (flight number), DateOfFlight, BookingNumber. The following
methods are available for this object:
FlightBooking.GetDetail returns detailed information on a booking
FlightBooking.CreateFromData creates a booking
FlightBooking.Cancel
FlightBooking.GetList returns a list containing details of all the bookings for that flight.
Generally displays fewer details for each booking than GetDetail.
Component
hierarchy
Application component
Business object
Key attributes
Hierarchy area
SAP AG 1999
You can display more information on business objects and the BAPIs that belong to them using
BAPI Explorer Information. The screen is in two parts: a hierarchy area and a details window. The
hierarchy area displays the component hierarchy. You can expand an application component to find
out which business objects belong to it. If you expand a single business object, the system displays a
sub-tree, showing you which key attributes and API methods belong to it. (API stands for
Application Programming Interface).
SAP AG 1999
Symbols are used to indicate business objects, key attributes, and BAPIs. You can display the key to
these symbols using the Display Legend button.
FlightBooking
AirlineCarrier
ConnectionNumber
DateOfFlight Key attributes
BookingNumber
Cancel
CreateFromData API methods
GetDetail
GetList
FlightCustomer
FlightConnection
SAP AG 1999
If you expand a sub-tree for a business object in the BAPI Explorer, the system displays the
following:
Key attributes, which provide a unique identifier for each business object
Instance-specific methods, which are methods that are bound to the instance identified by the key
attributes. The business object type FlightBooking has one instance-specific method, GetDetail
(which returns a structure with booking details). Key attribute values must be passed to this
method.
Non-instance specific methods, which can be called by all instances of an object type.
FlightBooking has one such method, GetList (which returns a list of all bookings, for which a
business object already exists at runtime).
Tool selection
FlightBooking
AirlineCarrier Business Object Builder
ConnectionNumber Function Builder
DateOfFlight ABAP Dictionary
BookingNumber BAPI Konsistenzprüfungen
BAPI Liste erstellen
Cancel
CreateFromData
BookingdataIn Dictionary Structure BAPISBDTIN
Return
Bookingdata
GetDetail Display
GetList
FlightCustomer
FlightConnection
SAP AG 1999
If you expand a substructure for a method, the system returns the names of its import and export
parameters. You can obtain more detailed information on the typing of interface parameters by
choosing the Tools tab, then choosing the ABAP Dictionary. BAPI interface parameters are always
typed using ABAP Dictionary types.
BAPIs usually have an export parameter called RETURN. This can be a structure or internal table.
The Return Parameter contains information on errors that occurred while the BAPI was being
processed. There are no exceptions for BAPIs.
O b je c t ty p e
B a s ic d a ta C o m p le te
b u s in e s s o b je c t
v ie w
I Inn t tee rr ff a c e s
K e y fie ld s
A tt r ib u t e s
M e th o d s
E v e n ts
SAP AG 1999
To display complete information on a business object type, use the Business Object Builder tool. The
system displays a tree structure for the business object type, including non-API methods.
To search for a business object, use the Business Object Repository (BOR) tool. This tool displays
the component hierarchy with all the business objects that belong to it. You can navigate from this
tree structure to the Business Object Builder. The system displays the relevant business object
automatically.
GetList
Returns the contents of the key fields for the object you have
chosen
GetDetail
Returns detailed information (attributes) for the required object
CreateFromData
Creates a new object in R/3 and returns information about it
SAP AG 1999
BAPIs with standardized names contain standard methods. Three of the most important are listed
here.
Tool selection
FlightBooking
AirlineCarrier Business Object Builder
ConnectionNumber Function Builder
DateOfFlight ABAP Dictionary
BookingNumber BAPI Konsistenzprüfungen
BAPI Liste erstellen
Cancel
CreateFromData
GetDetail
Function module BAPI_SBOOK_GETDETAIL
Return
Bookingdata
GetList
Display
FlightCustomer
FlightConnection
SAP AG 1999
In Release 4.6 BAPIs have been implemented using function modules. You can display the function
module for the BAPI you have chosen using the BAPI Explorer.
Select the BAPI in the hierarchy area.
In the detailed information display window, choose the Tools tab.
Choose Function Builder: The system displays the name of the function module.
Choose Display
ABAP Program
PROGRAM ...
R/3
TABLES ...
DATA ... Business Object
Repository
MODULE init OUTPUT.
CALL
CALL FUNCTION
FUNCTION 'BAPI_...'
'BAPI_...' ...
... Business object A:
ENDMODULE.
Method 1 = M1
MODULE read_data INPUT. Method 2 = M2
CALL FUNCTION
CALL FUNCTION 'BAPI_...'
'BAPI_...' ...
...
ENDMODULE. Function modules:
BAPI_A_M1
MODULE confirm_reservation.
CALL
CALL FUNCTION
FUNCTION 'BAPI_...'...
'BAPI_...' ... BAPI_A_M2
IF ... .
CALLFUNCTION
CALL FUNCTION'BAPI_...'
'BAPI_...'...
...
ENDIF.
ENDMODULE.
SAP AG 1999
If you would like to use a BAPI in an R/3 System, you can directly call the function module
containing it. Note that information about any errors that occur are passed to the program using the
interface parameter RETURN. BAPI function modules do not contain either exceptions or user
dialogs. They exist only to encapsulate business logic .
No exceptions
Errors are handled using exporting parameters (structures
or tables)
Parameter name: RETURN
ABAP Dictionary Structure (depends on Release):
BAPIRETURN, BAPIRETURN1,
BAPIRET1, BAPIRET2, BAPIRET2_FIX
SAP AG 1999
Every BAPI contains an interface parameter, RETURN, which contains information about errors that
occur. This parameter is always of an ABAP Dictionary type. This means that you must include a
structure of an identical type in your program.
Client
LUW 1 LUW 2
RFC - Session
SAP AG 1999
In Release 3.1, the BAPIs themselves execute the COMMIT WORK command, in other words, a
BAPI is synonymous with an LUW or transaction.
If a BAPI itself executes a COMMIT WORK command, it must be listed explicitly in the
documentation for the BAPI (as of Release 4.0). This is the only way in which the user can find out
that a COMMIT WORK is taking place in the BAPI.
These BAPIs must also be documented in the Online Service System (OSS) in note no. 0131838
"Collective note for BAPIs with 'Commit Work' command".
BAPI_TRANSACTION_COMMIT
Client
RFC - Session
SAP AG 1999
In Release 4.0A, the Commit control must be removed from the BAPIs that cause the database
changes. Here, the existing transaction model used in Release 3.1 should not be changed. For this
purpose, the RFC-capable function module BAPI_TRANSACTION_COMMIT, which performs the
COMMIT WORK command, must be called.
BAPI_TRANSACTION_COMMIT
Client
SAP LUW
Update task
RFC - Session
SAP AG 1999
In the transaction model used to develop BAPIs, a transaction represents a processing unit or Logical
Unit of Work (LUW).
Operations that change the database must be executed via the update.
As of Release 4.0, BAPIs no longer execute COMMIT WORK commands. This enables several BAPIs
to be combined with each other in an LUW.
To close LUW processing initiated by the BAPI calls, use the function module
BAPI_TRANSACTION_COMMIT. This module implements the TransactionCommit method of
the BAPISERVICE business object.
For further details on using BAPIs, see the BAPI User Manual and the BAPI Programming Guide.
These are available in the online documentation as well as on the SAP Homepage (http://www.sap-
ag.de) under Technology -> Open BAPI Network/ BAPI Section.
SAP AG 1999