Sie sind auf Seite 1von 34

BAPIS

BY ----Arjun

Overview
BAPI stands for

BUSINESS APPLICATION PROGRAMMING INTERFACE


It is also called as B+API BUSINESS OBJECT REPOSITARY (BOR) : It is a Repository of Business objects or container of Business objects. SWO1 is the tcode for Business objects

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 2

BusninessObject
BY ----Arjun

Overview
BUSINESS OBJECT(BO) :

It is an object which is similar to class, which is group of attributes methods, interfaces, key fields, events for a particular Business Application or Scenario.
SW01 is the TCODE for Business Object Repository Examples for Business objects are, BUS1001 Materials BUS2012 Purchase Order

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 4

Overview
BUS1001

Methods are :
BAPI_Material _Get detail BAPI_Material_GETLIST BUS2012 Methods are : BAPI_PO_GETDETAIL BAPI_PO_GETITEMS
SAP AG 2001, Smart Forms - the Form Printing Solution,
Claudia Binder / Jens Stumpe 5

Overview

What is BAPI?

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 6

Overview
BAPI:

It is also an Remote Enable function module which is used to communicate between SAP-SAP or SAPNONSAP servers.
Basically BAPI uses RFC Technology In the Initial stage it is a RFC Function module Later, this RFC Function module will be inserted into a business object, Now it is converted into BAPI.

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 7

Overview

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 8

Overview

Differences between RFC & BAPI

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 9

Overview
Both are used to communicate between SAP-SAP & NONSAP-SAP. Both are remote enabled FM The difference is, RFCs are called as Standalone Function Modules. BAPIs are part of Business Objects which are used to communicate with other BAPIs, events, Interfaces, attributes, Key fields etc., with in a single B.O. This is not possible with RFCs. Because they are standalone FMS
SAP AG 2001, Smart Forms - the Form Printing Solution,
Claudia Binder / Jens Stumpe 10

Overview

USAGE OF BAPIS

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 11

Overview

BAPIS are used in 3 scenarios.


1)Report generation using BAPIS 2)Using standard or custom BAPI to communicate between SAP & NONSAP 3)Using BAPIs for uploading data into SAP instead of BDC.

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 12

Overview

RULES FOR BAPIS

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 13

Overview
RULES FOR BAPIS:

Every BAPI should start with BAPI or ZBAPI.


All the Importing and Exporting parameters should be of Type structures, not the direct Data Types. All the structures must start with BAPI or ZBAPI. All the Parameters must be pass by Value because BAPIS doesnt support pass by reference. Every BAPI should have a returning Parameter by Name RETURN or BAPIRET2, to display success or error messages.
SAP AG 2001, Smart Forms - the Form Printing Solution,
Claudia Binder / Jens Stumpe 14

Overview
If BAPI is Success, we have to use another BAPI BAPI_TRANSACTION_COMMIT to Save the Data into Database Tables. If the BAPI has error, use another BAPI BAPI_TRANSACTION_ROLLBACK to revert back the changes made to the Database Tables.

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 15

Overview

Report generation using BAPIS

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 16

Overview
Reports:

Develop a Report which displays Material Details


ZBAPI_MAT_REPORT.txt Develop a Report which displays list of the Materials for a given Range. ZBAPI_MATNRSELECTION.txt

Develop a report which displays PO Details


Develop a report which displays list of items for a PO .

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 17

Overview

Developing Custom BAPI

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 18

Overview
Develop a Custom BAPI to display the Material details which can be used by NON-SAP. Step 1: Create structures for Importing and Exporting Parameters. Step2: Create a function module and make it as remote enabled. Step3 : Create a BO.

Step4 : Embed or insert RFC into BO so that it will be converted into BAPI.

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 19

Overview
Step 1: Create structures for Importing and Exporting Parameters. Go to SE11 Create a structure by Name ZBAPI_MATNR Create a single field MATNR.

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 20

Overview
Again Go to SE11

Create another structure by name ZBAPI_MARA


Create the fields MATNR, MTART, MBRSH, MEINS

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 21

Overview
Step2: Create a function module ZBAPI_MAT_GET_DET and make it as remote enabled Goto SE37 Create a function module ZBAPI_MAT_GET_DET Specify importing parameter as below with pass by value.

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 22

Overview
Specify Exporting parameter as below with pass by value. Ssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssssssssssss Specify returning parameter as below:

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 23

Overview
Write the below source code:

FUNCTION ZBAPI_MAT_GET_DET.
select SINGLE * from mara into CORRESPONDING FIELDS OF mara WHERE matnr = matnr . ENDFUNCTION. Save it. Make the FM as REMOTE ENABLED . Save, Activate and test it .
SAP AG 2001, Smart Forms - the Form Printing Solution,
Claudia Binder / Jens Stumpe 24

Overview
Step3 : Create a BO

Go to SWO1Give the BO name as ZYBUS1001


Click on CreateSpecify the details as below :

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 25

Overview
Put the cursor on methods

Click on Utilities API-METHODS ADD METHOD

Give the Function Module name as ZBAPI_MAT_GET_DET

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 26

Overview
Press enter

Click on NEXT STEP button

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 27

Overview
Again click on NEXT STEP button

A pop-up is displayed with below message

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 28

Overview
Click on Yes

Now our RFC is converted into BAPI


Click on SAVE Click on BACK

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 29

Overview
Goto Object Type Change Release Status Implemented

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 30

Overview
Again Go to Object Type Change Release Status Released

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 31

Overview
Now our Business Object is released and it can be visible/used by NON-SAP System Mapping from NON-SAP fields to BAPI fields will be done by NON-SAP Consultants. The Remote connection between SAP and NON-SAP Servers will be done by BASIS Consultants As an ABAP Consultant, our role is to develop a BAPI and give it to NON-SAP Consultants

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 32

Overview

BAPIS For uploading Data

SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 33

Overview

Business Requirement:

Develop a program for uploading material master data.

BAPI_MARAPROG.txt

MARA.txt
SAP AG 2001, Smart Forms - the Form Printing Solution,
Claudia Binder / Jens Stumpe 34

Das könnte Ihnen auch gefallen