Skip to Content

Web-services enhancement for MS Word integration in CRM 2007

As you know to create document template we must create web-service in the Web Service Tool and then create document template in template designer. But in Web Service Tool not all attributes are there.

In this blog I’ll tell you how to add custom attributes to web-service.

Business Scenario: We need to create document template for business transaction with these attributes:

  • Name and last name of business partner
  • Birth date of business partner Birth
  • Current date

Some of these attributes we cannot add with Web Service Tool: birth date and current date.

Solution: First of all we’ll create web-service with business partner’s name.

  1. Go to transaction BSP_WD_CMPWB, enter Component WS_DESIGN_TOOL and press Test button.

  2.  You are in Web Service Tool page, press New button to create new  web-service

  3. Input data like in print screen and press Next button
  4. You are in Select Attributes page, to add attributes you must select node, in right side select attributes then press Confirm button. We need these attributes:
  • Business Transaction – GUID of a CRM Order Object
    • Administrative Header of Order – GUID of a CRM Order Object
      • Parties Involved of Header – GUID of a CRM Order Object
        • Main Activity Partner – Partner number
          • BTPartnerAddress – First name, Last name

After this go to step 4 (Settings), save and activate your web-service. We created web-service and now we’ll enhance its output structure.

  1. Go to SE80 and open $WS_BOL_GEN package. Then we can open created web-service and see what function group is used.

  2. Open  this function group and its function module. In Export tab we’ll see its output structure:

  3. Open this structure and press Append Structure button, press Continue in dialog, then input new structure’s name, for example ZBPATTRIBUTES and input components.

  4. Save and activate your structure, activate output structure
  5. Go to web-service (change mode), press Check button and press Yes in appeared dialog

  6. Now additional attributes are added to web-service (you can see it in WSDL). Save and activate web-service.

In last step we’ll fill these attributes with  values.

  1. Go to functional module, press Enhance Source Code button (or press Shift+F4), then in menu Edit – Enhancement Operations – Show Implicit Enhancement Options. Now you can see where we can create enhancements in source code.

  2. Create declaration enhancement, input name and description.
  3. Input code and activate func. module:

    ENHANCEMENT 2  Z_BP_ATTRIBUTES.    “active version
    * Current Date
       DATE_INTERNAL = sy-datum

    *Date of birth
    data: ls_person_data TYPE BAPIBUS1006_CENTRAL_PERSON.
    data: lv_bupa_no         type BAPIBUS1006_HEAD-BPARTNER.


        input  = lv_bupa_no
        output = lv_bupa_no.

        BUSINESSPARTNER     = lv_bupa_no
        VALID_DATE               = SY-datum
        CENTRALDATAPERSON = ls_person_data.

    IF ls_person_data-BIRTHDATE IS NOT INITIAL.
       DATE_INTERNAL = ls_person_data-BIRTHDATE
       DATE_EXTERNAL                = output-Z_BIRTH_DATE.



Now everything is ready to use this web-service. Go to Web Service Tool and set Productive flag to your service in Settings page. You can test your service before it.

Now enter CRM WebClient with SALESPRO business role. Go to Sales Operations – Document Templates. Press new button, input parameters like in screen shot and press Start Designer.

Create test template like this:

Now create Appointment and test created template. As you can see our web-service works fine.

 I hope this blog will help you.

You must be Logged on to comment or reply to a post.
  • Hi Artur, nice job!

    I have one question about how these templates invoke or consume the webservice, is this triggered from inside CRM or SAP GUI? 

    Is it possible to use the templates in Word and consume the webservice to pull the data from CRM when a new document is created or using some Macro?

    • Hi Jose!

      Creating templates and assigning web-servises to them is a standard functional of SAP CRM 2007. You can create document with template for business objects like business partners or business transactions. This blog tells how to enhance these web-servises.

      Best regards,
      Artur Litvinov.

  • Hi Artur,

    In your blog you are extending the generated WebService with an implicit enhancemtn spot to add additioanl fields on your Word Template. However if you just want to use this WebService in Word Templates, why wouldn’t you use the default enhancemnt spot CRM_OFFICCE_INT_ENHANCEMENT which is created to add custom attributes and to perform value mapping in Word Integration.

  • Hi Artur,

    Thanks for a great blog post. I have followed the steps you have outlined, but when creating a Word template using the enhanced web service, the XML scheme is not displayed. Are you familiar with this issue?

    Kind regards,
    Johan Wigert

    • Hi Johan,

      were you able to resolve this Issue. because we also tried enhancing web service and th XML scheme is not appearing.

      Thanks & Regargds,
      Bhavesh P. Sanghavi

  • Hello Artur,

    I am from SAP CRM development and would like to point out one thing with regards to  this enhancement technique.

    The enhancements are done in the local $WS_BOL_GEN package and therefore cannot be transported to subsequent systems (e.g. from DEV to Q-System). SAP therefore does not recommend / support this enhancement concept.

    Best regards, Marek

    • Hello, Marek!

      You are right, in this case enhancements is not the best way, but when I wrote this blog nobody in SDN could solve this probled, so when I solved it myself I wrote this solution. Now I recomend to use CRM_WST_RT_ENHANCEMENT BAdI.

      Best regards,
      Artur Litvinov.

  • Hi Artur,

    first of all: nice job! I tried and it works fine for me. But I have a question regarding word or rather the grey placeholders ( [Firstname] [Lastname] ) you used in the screenshot. What kind of word function is this? In my templates I just use the given xml-structure which is a pain, because the output is never at the position I want it to be. How can I assure that the text is placed at the desired location.
    Thanks and Regards,

    • This attributes are from xml-structure of web-service created in step 4.

      Best regards,
      Artur Litvinov.

      • Hi Artur,

        I know how to retrieve those attributes. I was talking about the grey background in word. What kind of function is this? How did you define those fields? It seems that you defined something like a bookmark and put in the attributes.


  • Hi Arthur,

    I created a web service and then created a word template with Designer. As per your blog, if you populate the data in Exporting parameter “Output” in Finction module _READ then we will be able to see it on word template(if the variable is present on the template).
    But I can see the data populated in output structure but I am unable to see the data on word template.

    Are you aware of this Issue?

    Bhavesh P. Sanghavi. 

  • Hi. First all thanks for this blog.

    In one comment you said that you would now recommend to use different approach for ws enhancement by using CRM_WST_RT_ENHANCEMENT BAdI. Would it be possible for you to prepare another blog which would describe in details also this approach of ws enhancement.


    • Hello ,

      Is the new BADI ‘CRM_WST_RT_ENHANCEMENT’ explained in some blog.
      Please request you to send me the link or some steps how to implement this.


  • I have followed all the steps given by you upto point 4. But when I go to point 5 i.e.
    “5.Go to web-service (change mode), press Check button and press Yes in appeared dialog “
    and not getting the popup for service defination inconsistent and hence not finding the field in the attributes.

    Please reply what could be the problem.


  • Hi,

    I have done all the steps described in the blog, but the last step I did not complete successfully.
    When I start the template designer no offer structure OUTPUT of web service, the template is blank.
    The funny thing is that when I delete the APPEND structure with fields Z, and I press Check button and activate the web service again I have no problem, I start the template designer and reappear standard fields.

    Anyone have any idea what happens?


  • Hi,

    I am from CRM support team. You may not be able to access the XML schema in the template after enhancing the web service. We strongly recommend you to use the BADI ‘CRM_OFFICE_TEMPLATE_BADI’, if you want to add additional fields to your template that are not part of the webservice. Refer OSS note ‘1420943’ for more information on this.

  • Hello ,

    Is the new BADI ‘CRM_WST_RT_ENHANCEMENT’ explained in some blog.
    Please request you to send me the link or some steps how to implement this.


  • Now we will show the SAP BW data for other application, we apply the SAP standard WebService XMLA to retrieve the BW Cube or ODS data for external system, but the authorization for data scope is a question, I didn’t know how to pass the logon user name and password to the BW system,  the SAP standard WebService XMLA did not provide the paramters for input  these variants.
    So I want to enhance this webservice but didn’t know how to do it, if anyone know this please tell me, thank you very much!
  • Hello,

    thank you very much for your excellent blog! I am the responsible developer for word integration in SAP and we do not recommend to do any manual changes on the automatically generated artifacts.

    Instead, we could use AET to enhance the web service structure in a modification free way and such enhancement could be transportable. Maybe you can add my solution “How to enhance a web service response structure in word template integration” to the last part of your blog. Thanks a lot!

    Best regards,