Scenario: SAP provides a number of Standard BAPIs for all the modules to achieve the business process. But in very rare case we may need a custom BAPI our specific business needs. The below post shows the steps how we can create a custom BAPI.
*NB*- Save all the structures, FG and FM in a transportable package in order to create a Business object and API method.
Step1. Lets have the below table for the demo purpose.
Step2. Maintain Some table entries.
Step3. Create a Structure and it should contain name - ZBAPI* as it is to be used in the bapi function module creation.
Step4. Select the appropriate radio button.
Step5. Provide the below fields which are maintained in the above data base table, Save & Activate it.
Step6. In Tx- SE80 create a function group as our bapi function module needs to be assigned to the Function group. Activate the function group.
Step7. In Tx- SE37 create a Function module.
Step8. Provide the above created Function group and select Remote Enabled Module.
Step9. Provide the below fields in the Importing section. As this is Remote Enabled FM so the all parameters should be pass by value.
Step10. Provide below parameters in the Exporting section.
Step11. Provide below code in the Source code section & activate it. This just gets the employee details based on the Emp_ID input.
Step12. Then release the Function module.
Step13. After release the below message appears.
Step14. To Create the Business Object type Go to Tx- SWO1. Provide the Object name and click on Create button.
Step15. Provide the details and click on Continue Button.
Step16. Go to utilities and add an API Method.
Step17. Provide the Function module Name and Continue.
Step18. Provide the Texts and Click on the Right Arrow Button.
Step19. Again click on the Right Arrow Button.
Step20. Click on YES button.
Step21. Now to see the Method Details double click on it & U can see the details.
Step22. Details of the Method Under ABAP tab.
Step23. click on the highlighted button to see the status of the Business Object.
Step24. The Status of the BO is Modeled. Go Back.
Step25. From the EDIT menu navigate along the path and select To Implemented.
Step26. Again navigate to the Header section of the BO and we can see the Status is implemented. Go BACK.
Step27. Navigate along the Highlighted path under EDIT menu and Set the BO status to Released.
Step28. The status is set to released.
Step29. Go to the header Section & U can see the BO status is Released. Go BACK.
Step30. Now we have to release the method as well. Go to the Edit menu and navigate along the highlighted path to release it.
Step31. Double click on the method name and the status is released.
Step32. Click on the Program button.
Step33. The below program is automatically created. Sometimes this program can also be modified by the programmer as per the need. Go Back.
Step34. Lets test the Method. Select the method and click on the Test button.
Step35. Click on the F8 button.
Step36. Provide the Employee Id number as 0002 and click on the Execute button.
Step37. We received the below output. So the API Method works fine.
Step38. We find the newly created Business object Type in the Transaction - BAPI, click on the generate button or from the Menu choose Generate.
Step39. We received a message for teh generation.
Step40. Now go to Tx- BAPI and click on the Alphabetical tab. Here we can find the Business Object type.
Step41. Here we can see the business object API Method.
-------------------------------xxxx----------------------xxxx----------------------xxxx----------------------------------
*NB*- Save all the structures, FG and FM in a transportable package in order to create a Business object and API method.
Step1. Lets have the below table for the demo purpose.
Step3. Create a Structure and it should contain name - ZBAPI* as it is to be used in the bapi function module creation.
Step4. Select the appropriate radio button.
Step5. Provide the below fields which are maintained in the above data base table, Save & Activate it.
Step6. In Tx- SE80 create a function group as our bapi function module needs to be assigned to the Function group. Activate the function group.
Step7. In Tx- SE37 create a Function module.
Step8. Provide the above created Function group and select Remote Enabled Module.
Step9. Provide the below fields in the Importing section. As this is Remote Enabled FM so the all parameters should be pass by value.
Step10. Provide below parameters in the Exporting section.
Step11. Provide below code in the Source code section & activate it. This just gets the employee details based on the Emp_ID input.
Step12. Then release the Function module.
Step13. After release the below message appears.
Step14. To Create the Business Object type Go to Tx- SWO1. Provide the Object name and click on Create button.
Step15. Provide the details and click on Continue Button.
Step16. Go to utilities and add an API Method.
Step17. Provide the Function module Name and Continue.
Step18. Provide the Texts and Click on the Right Arrow Button.
Step19. Again click on the Right Arrow Button.
Step20. Click on YES button.
Step21. Now to see the Method Details double click on it & U can see the details.
Step22. Details of the Method Under ABAP tab.
Step23. click on the highlighted button to see the status of the Business Object.
Step24. The Status of the BO is Modeled. Go Back.
Step25. From the EDIT menu navigate along the path and select To Implemented.
Step26. Again navigate to the Header section of the BO and we can see the Status is implemented. Go BACK.
Step27. Navigate along the Highlighted path under EDIT menu and Set the BO status to Released.
Step28. The status is set to released.
Step29. Go to the header Section & U can see the BO status is Released. Go BACK.
Step30. Now we have to release the method as well. Go to the Edit menu and navigate along the highlighted path to release it.
Step31. Double click on the method name and the status is released.
Step32. Click on the Program button.
Step33. The below program is automatically created. Sometimes this program can also be modified by the programmer as per the need. Go Back.
Step34. Lets test the Method. Select the method and click on the Test button.
Step35. Click on the F8 button.
Step36. Provide the Employee Id number as 0002 and click on the Execute button.
Step37. We received the below output. So the API Method works fine.
Step38. We find the newly created Business object Type in the Transaction - BAPI, click on the generate button or from the Menu choose Generate.
Step39. We received a message for teh generation.
Step40. Now go to Tx- BAPI and click on the Alphabetical tab. Here we can find the Business Object type.
Step41. Here we can see the business object API Method.
-------------------------------xxxx----------------------xxxx----------------------xxxx----------------------------------
No comments:
Post a Comment