Developing Custom BAPI


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.
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.

Overview
Again Go to SE11

Create another structure by name ZBAPI_MARA
Create the fields MATNR, MTART, MBRSH, MEINS


 
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.


Overview
Specify Exporting parameter as below with pass by value.


 
Specify returning parameter as below:

 
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 .
Overview
Step3 : Create a BO
Go to SWO1àGive the BO name as ZYBUS1001
Click on Create->Specify the details as below :


 
Overview
Put the cursor on methods
Click on Utilities -> API-METHODS -> ADD METHOD


Give the Function Module name as ZBAPI_MAT_GET_DET

Overview
Press enter
Click on NEXT STEP button

 

Again click on NEXT STEP  button

 

A pop-up is displayed with below message 
Overview
  
Click on Yes

 Now our RFC is converted into BAPI

 Click on SAVE-> Click on BACK