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.
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:
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 |