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

Custom BAPI Creation

The document outlines the 8 step procedure for creating a custom BAPI in SAP: 1. Create BAPI import and table structures 2. Define a remote function module with import, export, and table parameters 3. Place the function module in the business object repository 4. Add the custom BAPI using the API method utility 5. Generate and release the BAPI 6. Test the BAPI using the execute button 7. Create a class to insert data into database tables 8. Create a program to call the class and insert sample data

Uploaded by

bharath_sajja
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
436 views

Custom BAPI Creation

The document outlines the 8 step procedure for creating a custom BAPI in SAP: 1. Create BAPI import and table structures 2. Define a remote function module with import, export, and table parameters 3. Place the function module in the business object repository 4. Add the custom BAPI using the API method utility 5. Generate and release the BAPI 6. Test the BAPI using the execute button 7. Create a class to insert data into database tables 8. Create a program to call the class and insert sample data

Uploaded by

bharath_sajja
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Custom BAPI creation - Step-by-step Procedure

To create the custom BAPI, we need to follow this step-by-step procedure. The steps are

1. 2. 3. 4.

Create the BAPI structure. Create Remote Function Module. Place the Remote Function Module into BOR (Business Object Repository). Implement, Generate and Release the BAPI.

Step 1: To create BAPI structure, the structure name should start with the keyword ZBAPI. Here, Two BAPI structures are created in this scenario .The name of these BAPI structures areZBAPI_IMPORT and ZBAPI_TABLE. Step 2: ZBAPI_IMPORT structure contains the following fields.

Step 3: ZBAPI_TABLE structure contains the following fields.

Step 4: Now, define the Remote Enabled Function Module using T-Code SE37 starting with theZBAPI . Provide the name of the function module as ZBAPI_DEMO_SD. We must pass the Importand export parameters as value parameters. Attribute Parameters:

Import Parameters:

Export Parameters:

Return parameter in the Export parameter contains the error messages. Here, we must create a parameter of type structure BAPIRETURN either in Export Parameter or Table Parameter. Table Parameters:

Source Parameter:

Step5: Place this Function Module in to BOR using the T-code SWO1. Provide the name of the object and press create button.

Provide the following details.

Step 6: Add our Custom BAPI using Utilities->API Method->Add Method

Now, Provide the created Custom Function Module name and click enter.

Press the Next Step Button.

Press the Next Step Button.

Click the YES button.

Now, Method is added in the BOR.

And Press Save button. Step 7: Now Implement the BAPI.

Now, Generate the BAPI by clicking symbol ball.

Lastly, Release the BAPI.

Step 8: Now test the BAPI by clicking Execute Button.

The following screen appears and click execute button.

Provide the sales document number and press execute button.

Now check the output as follows

Insert data into the database table using Classes


By Vikram Chellappa, Mouri Tech Solutions Go to Class Builder and create a new class

Provide the method name.

Go to parameters and provide the attributes.

Go back to methods. And provide the logic by double click on the method name.

Then save it, check it, activate it and execute it.

Press F8. The data is stored in database.

To verify, go to VBAK table (SE16) and check whether the data is stored or not.

Now we will create a program using the above class for inserting the data into the database table. Go to SE38 and create a program.

Select create button. After that provide the following logic. REPORT ZPG_INSERTINTODB. *provide the object for the class DATA: OBJ_INSERT TYPE REF TO ZCL_INSERTDB. *provide parameters PARAMETERS: V_VBELN TYPE VBELN, V_ERDAT TYPE ERDAT, V_ERZET TYPE ERZET. *provide work area DATA: WA TYPE VBAK. *create the object START-OF-SELECTION. CREATE OBJECT OBJ_INSERT. *provide insert method CALL METHOD OBJ_INSERT->INSERT_DATA *provide exporting parameters EXPORTING P_VBELN = V_VBELN P_ERDAT = V_ERDAT P_ERZET = V_ERZET *provide import parameters IMPORTING

WA_VBAK = WA. *display the data. WRITE:/ WA-VBELN, WA-ERDAT, WA-ERZET. Save it , activate it, execute it . The screen is like this.

Provide values.

Execute it.

Following is the sample output of the same:

You might also like