You are on page 1of 16

IBM Global Services

Use of BAPIs for Data Interfacing

Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Objectives

 The participants will be able to :


 Recall the basic techniques of using BAPI.
 Learn process flow of mass data transfer using BAPIs in the DX Workbench.

2 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Mass Data Transfer : Process flow

Extract Map

Clean

Load

We will discuss
use of BAPI in Check
detail in this
chapter

3 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Mass Data Transfer : Process flow (Contd.)

Extract Map

Clean

Load

We will discuss
use of BAPI in Check
detail in this
chapter

4 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

BAPI : Overview

 Business Application Programming Interfaces (BAPIs) are standardized


programming interfaces that provide external access to SAP business processes
and data.
 BAPIs are defined in the Business Object Repository (BOR) as methods of SAP
business objects or SAP interface types.
 BAPIs enable an object-oriented access to SAP application components.
 BAPIs are implemented and stored as RFC-enabled function modules in the
Function Builder of the ABAP Workbench.

5 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

BAPIs as Interfaces

 When using BAPIs as interfaces to the SAP System, the Workbench uses the
same technology as used with permanent data transfer via ALE between SAP
Systems or between SAP Systems and non-SAP systems.
 The data to be loaded must be in IDoc format. The IDoc numbers in the file must
be unique.
 When the task is started, the IDocs from the specified input files are read and
transferred to the BAPI.

6 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Why use BAPIs in Data Interfacing?

 The use of BAPIs is increasingly important, because the previous techniques are
only of limited or no use for data transfer from Release 4.6 onwards:
 The batch input procedure CANNOT be used for the new Enjoy transactions because
the batch input recorder does not support the controls used in these transactions.
 The administration transaction associated with the direct input method will no longer be
supported from Release 5.0 onwards (at the latest). This means that existing direct
input programs can be used, but the data transfer should be converted to BAPIs in the
medium term.
 When you use call transaction, you have to specify values for all the mandatory fields
on a screen. You can't update a single field, if there are some more fields which are
mandatory in the same screen. But, when you use BAPI you can update individual
fields without having to specify other fields.
 If you use CALL TRANSACTION you have to do a new recording each time the screens
of a particular transaction changes. But, if you are using BAPI to update fields, it does
not matter, where on the screen or in which screen a particular field resides. This is due
to the fact that BAPI updates through structures that are mapped directly with database
tables, so position of the fields on the screen does not matter.
 Data Interfacing through BAPIs greatly increase the performance as the updates are
done directly through structures.

7 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Developing BAPIs for Mass Data Transfer

 The following aspects are relevant for developing a BAPI that can be used for
mass data transfer in the DX Workbench:
 Implementing a BAPI
 BAPIs for mass data transfer must be developed as described in the BAPI Programming Guide.
All write BAPIs can potentially be used for mass data processing.
 Generating the BAPI-ALE Interface
 Since the data for the BAPI call is received in the SAP System in IDoc format, the BAPI-ALE
interface has to be generated to automate the mapping of the IDoc to the parameters of the
BAPI.
 Writing a report
 The report is responsible for writing existing R/3 objects in IDoc format to a file. This report is
required, since it is the only way for users to establish the connection between the online
transaction, the BAPI, and the IDoc.
 Registering a BAPI
 This step is required if the BAPI will be used in the DX Workbench. To register the
BAPI, including its corresponding report, use transaction BDLR.

8 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Process Flow of Mass Data Transfer With BAPI

Step 1: Analyzing the underlying structures

Generate default
Idocs for a BAPI
without application
Determine how the data
data used for BAPI is
to be represented in Generate Idocs for a
IDoc BAPI whose
parameters have
been filled with data
from an existing R/3
object

DX Workbench

9 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Process Flow of Mass Data Transfer With BAPI (Contd.)

Step 2:Mapping the non-SAP system data in SAP format

Mapping
External format data IDoc format of the
transfer file
LSMW/External
mapping tool

Transfer file
imported to
target system

10 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Process Flow of Mass Data Transfer With BAPI (Contd.)

Step 3:Performing the actual data import

Each IDoc is read and


it’s contents are
mapped to the
Transfer file parameters of If the BAPI
received in the corresponding BAPI call
target system fails,error
message
BAPI carries out is returned
required business in the
checks & updates BAPI
database. Return
parameter

11 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Use of BAPI in custom programs


LOOP AT <itab> INTO <work area>.
.. Populate all structures to be passed into BAPI
*Call BAPI to change material master data with future
*planned prices & future planned date.
Depending on
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA‘ destination,FM is
DESTINATION ‘RFC_DEST’ executed in
another R/3
EXPORTING
system.
headdata = t_headdata
valuationdata = t_valuationdata
valuationdatax = t_valuationdatax
IMPORTING
return = w_return 2 special system
exceptions with
EXCEPTIONS addition
COMMUNICATION_FAILURE = 1 MESSAGE MSG_TEXT DESTINATION
SYSTEM_FAILURE = 2 MESSAGE MSG_TEXT.
.. Handle w_return appropriately here.
ENDLOOP.
12 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation
IBM Global Services

Demonstration

 Using BAPI function modules instead of Call Transaction to update Material data.

13 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Practice

 Using BAPI function modules instead of Call Transaction to update Material data.

14 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Summary

 Mass Data Transfer technically involves 5 steps :


 Analysis & Cleanup of data in Non SAP system,
 Extraction of data from the non-SAP system,
 Mapping the data in SAP format,
 Transferring the data to the SAP System,
 Checking the data for consistency in R/3.
 The batch input procedure CANNOT be used for the new Enjoy transactions
because the batch input recorder does not support the controls used in these
transactions. Hence use of BAPI is becoming increasingly important.
 Data Interfacing through BAPI is performance efficient.

15 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Questions

 What is BAPI ?
 Why batch input procedure cannot be used with enjoy SAP transactions?
 What are the steps need to be performed to update data in SAP using BAPI ?

16 Use of BAPIs for Data Interfacing | Dec-2008 © 2005 IBM Corporation

You might also like