Chapter 12.3_Use of BAPIs for Data Interfacing

16
IBM Global Business Services © IBM Corporation 2013 Use of BAPIs for Data Interfacing | Dec-2008 Use of BAPIs for Data Interfacing

description

Chapter 12.3_Use of BAPIs for Data Interfacing

Transcript of Chapter 12.3_Use of BAPIs for Data Interfacing

Page 1: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

Use of BAPIs for Data Interfacing

Page 2: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

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.

Page 3: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

Mass Data Transfer : Process flow

We will discuss use of BAPI in detail in this

chapter

Clean

Extract Map

Load

Check

Page 4: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

Mass Data Transfer : Process flow (Contd.)

We will discuss use of BAPI in detail in this

chapter

Clean

Extract Map

Load

Check

Page 5: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

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.

Page 6: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

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.

Page 7: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

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.

Page 8: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

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.

Page 9: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

Process Flow of Mass Data Transfer With BAPI

Determine how the data used for BAPI is to be represented in IDoc

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

Generate default Idocs for a BAPI without application data

DX Workbench

Step 1: Analyzing the underlying structures

Page 10: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

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

External format data IDoc format of the transfer file

Mapping

LSMW/External mapping tool

Transfer file imported to target system

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

Page 11: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

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

Transfer file received in the target system

Each IDoc is read and it’s contents are mapped to the parameters of

corresponding BAPI

BAPI carries out required business checks & updates

database.

If the BAPI call

fails,error message

is returned in the BAPI

Return parameter

Step 3:Performing the actual data import

Page 12: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

Use of BAPI in custom programsLOOP 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.

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.

ENDLOOP.

2 special system exceptions with addition DESTINATION

Depending on destination,FM is executed in another R/3 system.

Page 13: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

Demonstration

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

Page 14: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

Practice

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

Page 15: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

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.

Page 16: Chapter 12.3_Use of BAPIs for Data Interfacing

IBM Global Business Services

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

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 ?