0% found this document useful (0 votes)
17 views

How To Create a Custom Bapi

BAPI

Uploaded by

swadhin_abap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

How To Create a Custom Bapi

BAPI

Uploaded by

swadhin_abap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

Cross Application: Sap Cross applications are part of the Interface which helps to transfer the data
between 2 systems.

With the help of cross-application, we can transfer the data between sap-to-sap, sap-to-non-sap, and
non sap-to-sap systems.

The Various cross-applications are Bapi, RFCs, IDOCs(ALE, EDI), etc.

Requirement: The customer will provide the employee data in the file and transfer that data into our
custom table using BAPI.

we will migrate the data in SAP using bapi with idoc interface.

step 1: - Creation of BAPI.

Step 2:- Migrate the employee data using the business object method (BAPI).

q). What is BAPI?

Business Application Programming Interface, Bapi is an interface that enables external access to the
business process of the SAP system.

we have billing documents, material creation, and sales order creation.

the external system is getting access to those business processes through Bapi only, the external system
will send the data to Bapi and baPi will create all those things like sales orders.

an external system can be a sap or a non-sap system ( which uses other languages like java, c++, or
Visual Basic) can be called bapi.

bapi in the sap system is implemented in the form of a function module only.

bapi = fm + business object. (Bapi is a function module having a business object) if that function module
doesn't has any business object then it is not a bapi.

once we create the fm then we will create a business object then our bapi will be defined in the business
object repository we will simply be called as BOR. Once our BAPI is ready we have a dedicated t-code
BAPI (BAPI explorer). there we can check our bapi there.

1
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

2
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

First Let's create a Function group to create a function module

The Function Group is a Container for the Function Module.

Now let's create an FM

Prerequisite for bapi :

1). Function module name must starts with <namespace> BAPI <business_object>_<method>.

2). All parameters associated type must begin with <namespace> BAPI

3). All Parameters must be pass-by value.

4). It must contain a parameter return of type 'BAPIRET2'.

5). Function Module must be RFC enabled.

6). Function module must be released (GOTO-> release)

Let's create FM

3
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

in importing, exporting we define our parameters and in source code, we write the logic

we fulfill our first requisite.

4
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

For the second prerequisite, we need to create a type with Zbapi to fulfill our second prerequisite.

Let's create a structure for 2 fields.

now let's pass this structure to Zbapi to fulfill our second prerequisite.

if you dont wanna go with structure type and want to go single parameters then you can also go with
that also.

You can give in this way also.

5
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

Let's Fulfill our 3rd prerequisite.

4th prerequisite must be passed by value of all import parameters.

Let's write logic in the source code.

6
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

our 5th prerequisite

7
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

Fm must be rfc.

Now left with last prerequisite.

Our status is not released.

8
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

It is fully released.

Now let's create a business object through t-code swod.

Object type - internal identification of the business object (to identify the business object within sap ).

Supertype - you are creating a new object type with the help of an existing type. Or to inherit the
component of the existing object type.

Object name - it is the external identification of business object (using this property external system can
interact with sap system).

External identification of business objects.

Name- a descriptive name of the business object. (business object for employee data).

Program - abap code for a business object

Zprg_employee

Application - * (cross-application)

9
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

10
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

we need to bind our fm here.

11
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

Give the name of fm which you want add

Click on next step

NEXT STEP

12
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

You will see method create inserted.

Click on program to show the details of it.

13
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

There are 4 types of status in business objects:

1) modeled - whenever you are defining things the status will be modeled (components of the business
object )

2). implemented - the business object components have got full functionality implemented and these
can be used for internal purpose (within sap ) and for testing purpose.

3) . Released - once it is released only it can make entry in bapi Explorer and can be invoked from an
external system (non-sap).

4). Obsolete - can't be used.

As of now, the status is modelled.

Let's make it implemented so that we can test it internally.

14
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

15
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

At the top, we have a test button here to test our bapi.

We will do internal testing

It is inserted successfully.

Let's check value at the se11 table

16
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

Let's insert 5 again in ztable.

Getting error msg.

For now, in bapi t-code there is no bapi with the name employee

17
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

Let's change the status to release.

18
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

It is now released but it will not show it in bapi t-code because we need to also generate it.

Note: for release, you need to save it in the Custom package.

19
Made By Rahul Sharma SAP ABAP ASSOCIATE CONSULTANT

Compare customized and standard business object

Everything same

Table used in business object - tojtb, swotlv

We created the rfc fm ,

Bapi - business object

20

You might also like