Вы находитесь на странице: 1из 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.

Use of BAPIs for Data Interfa

Dec-2008

2005 IBM Corporation

IBM Global Services

Mass Data Transfer : Process flow

Extract

Map

Clean
Load
We will discuss
use of BAPI in
detail in this
chapter

Use of BAPIs for Data Interfa

Check

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
detail in this
chapter

Use of BAPIs for Data Interfa

Check

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.

Use of BAPIs for Data Interfa

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.

Use of BAPIs for Data Interfa

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.

Use of BAPIs for Data Interfa

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.

Use of BAPIs for Data Interfa

Dec-2008

2005 IBM Corporation

IBM Global Services

Process Flow of Mass Data Transfer With BAPI


Step 1: Analyzing the underlying structures

Determine how the


data used for BAPI is
to be represented in
IDoc

Generate default
Idocs for a BAPI
without application
data
Generate Idocs for a
BAPI whose
parameters have
been filled with data
from an existing R/3
object

DX Workbench

Use of BAPIs for Data Interfa

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

External format data

Mapping
LSMW/External
mapping tool

IDoc format of the


transfer file

Transfer file
imported to
target system

10

Use of BAPIs for Data Interfa

Dec-2008

2005 IBM Corporation

IBM Global Services

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


Step 3:Performing the actual data import

Transfer file
received in the
target system

Each IDoc is read and


its contents are
mapped to the
parameters of
corresponding BAPI

BAPI carries out


required business
checks & updates
database.

11

Use of BAPIs for Data Interfa

Dec-2008

If the BAPI
call
fails,error
message
is returned
in the
BAPI
Return
parameter

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
Depending on
destination,FM is
executed in
another R/3
system.

*planned prices & future planned date.


CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA
DESTINATION RFC_DEST
EXPORTING
headdata

= t_headdata

valuationdata = t_valuationdata
valuationdatax = t_valuationdatax
IMPORTING
return

= w_return

EXCEPTIONS
COMMUNICATION_FAILURE = 1 MESSAGE MSG_TEXT
SYSTEM_FAILURE
= 2 MESSAGE MSG_TEXT.
.. Handle w_return appropriately here.

2 special system
exceptions with
addition
DESTINATION

ENDLOOP.

12

Use of BAPIs for Data Interfa

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 Interfa

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 Interfa

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 Interfa

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 Interfa

Dec-2008

2005 IBM Corporation

Вам также может понравиться