Nov 03

Changing The Function Interface of Web Service Enabled Functions

Today, I got an email from one of my co-workers at my client with a very good question.  This developer had created an ABAP function to return SAP data.  Then, he exposed this function as a web service. Due to changes in functional scope, he had to change the function interface.  After he made all his changes and unit tested the ABAP code, he was surprised to find that his web service was still adhering to the old function interface.  He tried deleting and recreating the web service, but ran in to problems.  He was stuck in a pickle and needed a little push in the right direction.

My colleague, Steve Park, wrote a two part blog explaining how to turn any ABAP function into a web service.  (Find Part 1 here.  Find Part 2 here.)  But, what happens when you change the function module interface as my friend in the above example did?  SAP does not automatically update the web service interface (called the virtual interface).  You have to manually rectify this conflict.  There are two main options to do this.  Both are quite easy.  Which option you choose depends on how the external systems consuming the web service are handling changes.

Note: The examples listed below are for ECC 5.0.

Option 1: Update Virtual Interface

In cases where all systems consuming the web service will be using the new function/web service interface, when the underlying structure of complex data type changes, or when mandatory fields of a function interface are added or removed, it is best to change web service virtual interface.  The consuming application may have to re-import the WSDL to

In transaction SE80, navigate to the virtual interface for the function whose interface has changed.  Right click on the virtual interface and select “Change”.

Change Virtual Interface 01

SAP will compare the virtual interface to the function interface.  If the interfaces are different, SAP will display the following prompt.

Change Virtual Interface 02

Simply select “Yes” and SAP will update the virtual interface to match the function interface.  Once you have activated your changes, you can check the WSDL to ensure that the function interface changes have been successfully migrated to the web service virtual interface.

Option 2: Create new virtual interface version

In cases where optional fields are added to the existing function interface and/or when some of the web service consumers will NOT need to use the new function interface, it is possible to create a new virtual interface version.  This is possible only in cases where the old virtual interface can still execute the function module with the new interface without causing syntax errors.

In transaction SE80, navigate to the virtual interfaces for the function whose interface has changed.  Right click on the virtual interface node and select “Create”.

Change Virtual Interface 03

In the ensuing dialog, create a new virtual interface version with the endpoint mapped to the  function module.

Change Virtual Interface 04

Now that the virtual interface is created, create a new version of the web service.

Change Virtual Interface 05

Conclusion

Changing the web service virtual interface to match changes in the underlying function module interface is easy. Whether you choose to create a new virtual interface version, or if you choose to update the virtual interface to match the new functional interface, the process is quick and easy.

Avatar

About The Author

Former Partner and Senior Consultant at DataXstream, Craig Stasila played a key role in developing DataXstream. For current information regarding Craig Stasila please see his Linkedin profile.

3 Comments

  1. Avatar
    CSDN2008
    March 18, 2010 at 7:21 am · Reply

    Thanks a lot.

    I have a question about it, i find i cannot find the “virtual interface ” folder in SE80, because my SAP is ECC6.0, your example is ECC5.0. So, would you please tell me, how to process it under ECC6.0?

    Thanks again.

  2. Avatar
    Luis Lara
    July 6, 2010 at 2:37 am · Reply

    CSDN2008, in SE80 you have to go to Repository information System and have a look under the folder Enterprise Services.

    Best Regards:

    Luis

  3. Avatar
    Cengiz
    March 24, 2011 at 11:37 am · Reply

    Hello Craig,

    Thanks a lot. It’s a very nice and imported information.

    I have only 1 question:
    I have a webservice created from FM but I do not have a virtual interface.
    I only have a Service Definition. When checking the service definition it prompts inconsistancy and has to be reconstructed.
    Do have an idea how to execute the reconstruction? Selecting “Change” does not prompt for adjustment etc….

    Thanks in advace.

    Kind regards,
    Cengiz

Leave a reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

This site uses Akismet to reduce spam. Learn how your comment data is processed.