Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

CREATING BAPI

Former Member
0 Kudos

my actual requirement is creating

 BAPI for displaying the Customer details based on sales organization, Distribution channel and Division.

?  BAPI for deleting purchase orders using bapi_po_change.

help me in this how to create bapi structure and function module and object forthis and how to release object and function module for this.help me i this.

2 REPLIES 2

manubhutani
Active Contributor
0 Kudos

Create a Remote enabled Function module firsst..

then you need to add this BAPI in Business Object Repository

Please award points

manubhutani
Active Contributor
0 Kudos

1. Yes we can create new BAPI, BADI .

2. Create BAPI steps:

Programming a BAPI consists of some tasks like:

• Defining BAPI Data structures ( using SE11 )

• Creating BAPI Function Modules (For each method)

• Defining BAPI Methods in the BOR

• Generate and release

1. Defining BAPI Data structures: This is the basic step followed while creating BAPIs. All the relevant structures that are required for BAPI have to be created using T-Code SE11. The structures can be created for Import/Tables parameters.

2. Creating BAPI Function Modules: We must create new function group for each BAPI. If the BAPIs are related then the same can be grouped under the same FUNCTION GROUP to enable the sharing of global data amongst the related BAPIs.

3. Defining BAPI Methods in the BOR: When creating a new object type in BOR (Business Object Repository), there can be two possibilities. Either it is created as a subtype of an existing business object or it is created as a new business object from scratch. Create a business object using the T-Code SWO1. The business object gets created with the standard interface that contains an Interface IFSAP, an Attribute ObjectType, and two methods namely ExistenceCheck and Display. All these cannot be changed. You can add a method to the business object. For this, we will choose from the menu path, Utillities -> API methods -> Add method. To use the business object Object type status has to be set to Implemented.

4. Generate and Release: Go to SE37 and release the API enabled Function module. In the Object created in the BOR, set the status of Object Type Component to Released.

You can then display the BAPI in the BAPI Explorer. Invoke the same using the T-code BAPI.

Create BADI Steps:

Go to SE18. Enter the definition name. Click on Create.

In attributes, Enter short description for BADI and click on checkbox Multiple Use.

Go to Interface tab. Double-click on Interface name which will take you to class builder screen.

Enter Name of Method, Level and Description.

Define Parameters for the method.

Save, Check and Activate. Adapter class proposed by system, ZCL_IM_IM_LINESEL, is generated.

Go to SE18. Enter the Definition name. Go to Implementation -> Create.

Enter Implementation Name.

Enter Implementation short text.

In Interface tab, Double click on Method Name to insert implementation code.

Enter code between Method and Endmethod statements.

Check and Activate.

Go to SE38. Create report to use created BADI.

3. Find BADI

There are multiple ways of searching for BADI.

• Finding BADI Using CL_EXITHANDLER=>GET_INSTANCE

• Finding BADI Using SQL Trace (TCODE-ST05).

• Finding BADI Using Repository Information System (TCODE- SE84).

1. Go to the Transaction, for which we want to find the BADI, take the example of Transaction VD02. Click on System->Status. Double click on the program name. Once inside the program search for ‘CL_EXITHANDLER=>GET_INSTANCE’.

Make sure the radio button “In main program” is checked. A list of all the programs with call to the BADI’s will be listed.

The export parameter ‘EXIT_NAME’ for the method GET_INSTANCE of class CL_EXITHANDLER will have the user exit assigned to it. The changing parameter ‘INSTANCE’ will have the interface assigned to it. Double click on the method to enter the source code.Definition of Instance would give you the Interface name.

2. Start transaction ST05 (Performance Analysis).

Set flag field "Buffer trace"

Remark: We need to trace also the buffer calls, because BADI database tables are buffered. (Especially view V_EXT_IMP and V_EXT_ACT)

Push the button "Activate Trace". Start transaction VA02 in a new GUI session. Go back to the Performance trace session.

Push the button "Deactivate Trace".

Push the button "Display Trace".

The popup screen "Set Restrictions for Displaying Trace" appears.

Now, filter the trace on Objects:

• V_EXT_IMP

• V_EXT_ACT

Push button "Multiple selections" button behind field Objects

Fill: V_EXT_IMP and V_EXT_ACT

All the interface class names of view V_EXT_IMP start with IF_EX_. This is the standard SAP prefix for BADI class interfaces. The BADI name is after the IF_EX_.

So the BADI name of IF_EX_CUSTOMER_ADD_DATA is CUSTOMER_ADD_DATA

3. Go to “Maintain Transaction” (TCODE- SE93).

Enter the Transaction VD02 for which you want to find BADI.

Click on the Display push buttons.

Get the Package Name. (Package VS in this case)

Go to TCode: SE84->Enhancements->Business Add-inns->Definition

Enter the Package Name and Execute.

Here you get a list of all the Enhancement BADI’s for the given package