Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
JerryWang
Product and Topic Expert
Product and Topic Expert
340,877


This document could be used as guide for beginners to learn and use ABAP web service.

How to create web service provider in ABAP system


The following steps demonstrates how to expose a function module as a web service provider in SAP CRM system.


1. create a new function module to return product description by given input product ID.


Signature and source code of function module:



FUNCTION ZGET_PROD_DESCRIPTION.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_PROD_ID) TYPE COMM_PRODUCT-PRODUCT_ID
*" EXPORTING
*" VALUE(RV_TEXT) TYPE STRING
*"----------------------------------------------------------------------
SELECT SINGLE A~short_text INTO rv_text FROM COMM_PRSHTEXT AS A
INNER JOIN comm_product AS B ON B~product_id = iv_prod_id AND B~product_guid = A~product_guid.
ENDFUNCTION.

Make sure the FM is marked as "Remote enabled".



2. start the web service creation wizard:



Just follow the wizard to finish creation. Choose the appropriate authentication approach according to your use case.



3. Once creation is finished, you would find your service definition as below:



click tab WSDL, write down your WSDL link:



4. use tcode SOAMANAGER, click Web Service Configuration



you can find your service definition created just now:



click the hyperlink and create a new service:



For security reasons choose radio box "SSL".



click Finish button:



Now your web service is ready for consumption. click this icon:



write down this link for later usage.


How to consume web service in ABAP system


1. tcode SE80, create a new service consumer:



2. Choose external WSDL:



choose the url got from last step of chapter "How to create web service provider in ABAP system":



activate your consumer proxy and write down the ABAP class name.



3. go back to SOAMANAGER, find the consumer proxy created in step2:



create a new logical port:




4. Make sure you specify URL got from the last step of web service creation chapter. If you just use the URL got from SE80 in tab "WSDL", you will meet with below error.



5. consume the web service in ABAP report:


you can find the data type for input and output parameters in SE80:




data: lr_proxy TYPE REF TO CO_ZPRODUCTDESCRIPTION4,
input TYPE ZGET_PROD_DESCRIPTION,
output TYPE ZGET_PROD_DESCRIPTION_RESPONSE.
input-iv_prod_id = 'ARNO_TEST004'.
CREATE OBJECT lr_proxy
EXPORTING
LOGICAL_PORT_NAME = 'ZLP_JERRY1'.
CALL METHOD lr_proxy->ZGET_PROD_DESCRIPTION
EXPORTING
input = input
IMPORTING
output = output.

Now we execute the report and get the web service execution result as expected:



The product description in UI:




How to trace the web service execution


Use tcode SRT_UTIL, add a new configuration for your user which triggers the web service call:


Set the Functional Trace to "High". You could also enable Performance and Payload trace if necessary.


Click Save Configuration button to persist the change.



Execute the report which triggers the web service call. After it finishes, click tab "Functional Trace" and click refresh button, you should see several records for execution trace.



Double click and select the row with type "Response", where you could find the product description value returned by service provider.




21 Comments
Labels in this area