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: 

how to create a own badi and bapi

Former Member
0 Kudos

hi,

can u explain how to create a own badi and bapi and can u give me steps which is how to create this...

Regards,

kumar

8 REPLIES 8

Former Member
0 Kudos

For how to create Bapi refer

For how to create Badi refer

Former Member
0 Kudos

Hi,

Give me your Mail Id , i will send step by Step Proceedure.

Thanks,

Anitha

0 Kudos

Hi Anitha,

Please send to me also.

thanks in advance.

Regards,

Irfan

Former Member
0 Kudos

Hi,

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.

Regards,

Priyanka.

Former Member

Former Member
0 Kudos

FOR BADI USE SE18 AND SE19

THEN GO TO TCODE BAPI AND CHECK

ONLY 5 STEP PROCESS

CREATE FUNCTION MODULE

CREATE API

REALEST FUNCTION MODULE

REALEST API

ALL SHOULD BE DONE IN SE80 ITSELF

Former Member
0 Kudos

FOR BAPI WE CAN CERATE BY LOT OF WAYS

WE CAN USE FUNCTION MODULES LIKE BAPI_PO_CREATE

BAPI_SO_CERATE

Former Member
0 Kudos

hI

Please go through the Following steps

BAPI Step by step Guidance

BAPI stands for Business Application Programming Interface.

These are the different steps in BAPI.

- Create BAPI Structure

- Create BAPI Function Module or API Method.

- Create BAPI object

- Release BAPI Function Module.

- Release BAPI object.

Step1. Creating BAPI Structure:

- Go to <SE11>.

- Select Data Type & Enter a name.

- Click on Create.

- Note: Always BAPI should be in a development class with request number (Not Local Object).

- Select Structure & hit ENTER.

- Enter the fields from your database. Make sure that the first field is the Primary Key Field.

- Then SAVE & ACTIVATE.

Step 2. Creating BAPI module:

- Enter TR.CODE <SE37>.

- Before entering any thing, from the present screen that you are in, select the menu

Goto -> Function Groups -> Create Group.

Enter a name (Note: This name Must start with ZBAPI)

Let this screen be as it is and open another window and there, enter TR.CODE <SE80).

Click on the Third ICON that says Inactive Objects.

Select the group that you just created and click on Activate.

Notice that the group you created will disappear from the list of inactive objects.

- Go back to ><SE37> screen and enter a name and hit <ENTER>. Then enter the group name that you just created and activated.

NOTE: When you release a function module the respective group will be attached to that particular application. It cannot be used for any other application. NEVER include an already existing group that is attached to another module.

Now click on the first Tab that says [ATTRIBUTES] and select the radio button that says remote-enabled module since we will be accessing this from any external system.

Then click on the second tab that says [IMPORT].

Enter a PARAMETER NAME, TYPE and the structure you created in the first step. Also select the check box ‘Pa’. All remotely enabled functional modules MUST be Pa enabled, where Pa means ‘Passed by Value’ and if you don’t select ‘Pa’, then that means it will be passed by reference..

Then click on tab that says [EXPORT].

Enter the following as is in the first three fields

RETURN TYPE BAPIRETURN (These 3 field values are always same)

Here also select ‘Pa’ meaning Pass by value.

Note: BAPIRETURN contains structure with message fields.

Then SAVE and ACTIVATE.

Step 3. Creating BAPI object: - Enter Tr.Code <SWO1> (Note. It is letter ‘O’ and not Zero).

- Enter a name and then click on create. Enter details.

NOTE: Make sure that that Object Type and Program name are SAME.

- Enter Application ‘M’, if you are using standard table Mara. If you are using your own database then select ‘Z’ at the bottom.

- Then hit <ENTER>.

- Now we have to add ‘Methods’. High light METHODS and then select the following from the menu:

Goto Utilities -> API Methods -> Add Methods.

- Enter function Module name and hit <ENTER>.

- Select the second FORWARD ARROW button (>)to go to next step.

- Check if every thing looks ok and again click on FORWARD ARROW button (>).

- Then select ‘YES’ and click on <SAVE>.

- Now on a different screen goto TR.CODE <SE37>. Enter Function Module name and select from the top menu Function Module -> Release -> Release.

- Goback to TR.CODE <SWO1>.

Here select the menu combination shown below in the same order.

- Edit -> Change Release Status -> Object Type Component -> To Implemented.

- Edit -> Change Release Status -> Object Type Component -> To Released.

- Edit -> Change Release Status -> Object Type -> To Implemented.

- Edit -> Change Release Status -> Object Type -> To Released.

- Then click on <SAVE>.

- Then click on Generate Button (4th button from left hand side looks like spinning wheel).

- Then Click on the button that says ‘PROGRAM’ to see the source code.

To check if this is present in work flow goto TR.CODE <BAPI>.

Here it shows business object repository.

- First click on the middle button and then select “ALL” and hit ENTER.

- Goto tab [ALPHABETICAL] and look for the object that you created. This shows that the BAPI object has been created successfully

Reward if helpful