Skip to Content
Author's profile photo Former Member

Web Service creation and consuming it In SAP ABAP

Business Scenario: Creating a function module. Creation of  Service Definition from function module and creation of service consumer to consume the Service Definition.


Step1. Go to Tcode- SE80 to create a Function group.

Step2. Select the Function Group and Provide the function Group name and hit the Enter button.

Step3 Provide short description and click on SAVE button.

Step4. Navigate along the highlighted path to create a function module.

Step5. Provide the Function module name, description and click on SAVE button.

Step6. Provide the importing parameters.

Step7. Provide the exporting parameters .

Step8. Provide below code to add two numbers and activate the function  module.

Step9. Navigate along the highlighted path to create Enterprise Service.

Step10. Provide the Service Name and description and click  on continue button.

Step11. Click on continue button.

Step12.  Click on continue button.

Step13. Select the highlighted values and Click on continue button.

Step14. Select as local object and Click on continue button.

Step15. Click on Complete button to finish the Service definition creation.

Step16. Activate the service definition ‘ZWS_ADDITION’.

Step17. Go to the Internal View tab to see the details.

Step18. To create the binding for the service definition go to the Tcode- SOAMANAGER.

Step19. Click on WEB SERVICE Configuration under Service Administration.

Step20. From the Search tab, Select Service Definition and provide the service definition name ‘ZWS_ADDITION’ and click on Go button.

Step21. Select the Service definition and click on Apply Selection button as highlighted.

Step22. Go to Configuration tab to create the Binding.

Step23. Click on Create Button.

Step24. From the Pop up Modify the Service Name, description and Binding Name if needed and click on apply settings button.

Step25. Select the below highlighted buttons and Save it.

Step26. Now the binding is Active and click on Overview Tab.

Step27. Click on ‘Open WSDL document for selected binding or service’.

Step28. The WSDL of the Service definition is displayed in a new browser window.

Step29. Now click on ‘Show/Hide selected Binding or Service’s WSDL URL’ to display the web service definition URL. Copy the URL to be used later.

Step30. Now the Service definition is created with WSDL and URL. Go to Tcode- SE80 to create the Service Consumer.

Step31. Select the package and navigate along the highlighted path.

Step32. Select the Service Consumer button and click on Continue Button.

Step33. Select External WSDl and click on Continue Button.

Step34. Select the URL button and Click on Continue button.

Step35. Provide the URL generated in the Service Definition creation time and click on Continue button.

Step36. Select the Local Object and Provide the Prefix name and click on Continue button.

Step37. Click on COMPLETE button.

Step38. Provide the USER credentials and click on OK button.

Step39. The Proxy name ‘ZCLCO_ZWS_ADDITION’ is generated with is a class. Now Activate the Service Consume ‘ZWS_ADDITION’.

Step40. Now double click on the Proxy Name ‘ZCLCO_ZWS_ADDITION’.

Step41. The Function module now appears as a method of the class. Double click on the importing parameter type and exporting parameter type as highlighted.

Step42.  The Input Structure.

Step43.  The output Structure.

Step44. Now go to Tcode- SOAMANAGER to create a logical port for the service consumer.

Step45. Select WEB SERVICE Configuration under Service Administration tab.

Step46. From the search tab, select Consumer Proxy and provide the Consumer proxy name and click on go button.

Step47. Select the Consumer Proxy and click on Apply Selection button as highlighted.

Step48. Click on Configuration Tab.

Step49. Click on the Create button.

Step50. Provide a logical port name, description. Provide the Service Definition URL and user details and click on Apply Settings button.

Step51. Select the Binding created in the Service definition phase and click on Apply settings button.

Step52. Provide the User details and Save the Port ‘ZADD_PORT’.

Step53. Now the port ‘ZADD_PORT’ is active.

Step54. Now click on Overview tab to see the details.

Step55. Now go to the service consumer and click on Execute button to consume the Service.

Step56. From the appearing screen provide the above created port ‘ZADD_PORT’ and click on  execute button.

Step57. Thee value of NUM1 = 1 and NUM2 = 2. Click on Execute button.

Step58. The result is 3.

Step59. Go back and again click on the Execute Button. To change the Input values click on the highlighted button.

Step60. Change the input number values and click on execute button.

Step61. The result appears as shown below.

Step62. Lets create a report program to call the web service to consume it.. So go to Tcode- SE38.

Step63. Provide the below code and activate and execute it. Instantiate the class ZCLCO_ZWS_ADDITION’ and call the method ‘ZNUM_ADD’ .

Step64. The Result as follows:


Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.