SAP CRM如何建立支援Web Service的WORD模板
In CRM webclient UI there is a reuse assignment block “Attachment” which are available for most of CRM application.
There is a button “With Template” which allows you to create word document whose content will automatically be filled by the web service created by you via web service tool in CRM. This document explains how to archive this step by step and illustrate the technical detail behind it.
This feature is especially useful if you need to fulfill the scenario to create lots of documents for business transaction like Sales order and the document content consists of both static text and dynamic values like Order ID, Order description etc. Then you just need to create a single document template with all static text, and those dynamic values could be filled by web service in the runtime.
In this document I will create such word document for Product as example. The logic is exactly the same if you could like to create web service enabled document for others such as Sales Order, Service order, Opportunities etc.
(1) Create your own web service which will be consumed by your word document. As Arjun Pawar has already written an excellent document All about Web services – Web Service Tool, I will not repeat the detailed creation steps, but just include the productive web service I created:
There are some important attributes which we can write down for later usage: a. I specify BOR type BUS1178 for my web service b. The Genil component PROD is assigned to my web service together with its root node “Product” c. I have only enabled “Read” operation for my web service d. There is one function group automatically generated: /CRMOST/JERRY_PROD_WS_FCT. We will discuss it later.
(2) Download the word plugin “SAP Data Panel” from service market place. This wiki could guide you how to download and install in your computer. If you encounter any problems, feel free to contact me.
After successful installation, create a new word document and you will see a new menu “SAP”:
It should appear in Active Application Add-ins in your Word option.
(3) Create a new word template. Work center “Service Operation”,
Fill all mandatory fields like below and click “Start Designer” button:
click Open in new popup:
Then a new empty word document is opened. In the right part, the “SAP Data Panel” Addin will display all fields available in root node Product of Genil component PROD as a tree, the root node is named “JerryProdWs”, which is just the web service we created in step1. Now you can edit this word template by adding the static part like header, footer, field label. Just select the field in the SAP Data Panel, drag it into the left part and drop.
This is the final version of my word document. If you put the mouse over the dynamic fields which are dragged from SAP Data Panel, it will be marked with a grey rectangle as a hint that it is dynamic.
Once click, the technical name will be displayed on top of it.
Now since I already finish the template edit, I could directly close the word application.
(4) Go to Product application, click “With Template” button:
in popup choose the template created in previous step:
Then the word application is automatically launched with all dynamic data filled as expected:
Close the word application and then this document will be saved and appear in the attachment assignment block:
Automatically generated Artifacts after web service creation
In step1 after web service creation we write down the function group name /CRMOST/JERRY_PROD_WS_FCT.
In fact there are other artifacts automatically generated by system which are necessary for web service runtime processing: You will find the function group in package $WS_BOL_GEN ( all function group for other web service are also put here ) Since I have only enabled Read Operation during web service creation step, so within this generated function group there is only one generated function module which will delegate the web service call to the method GET_OBJECTS of Genil implementation class CL_CRM_PRODIL of genil component PROD.
also the generated DDIC structure for web service input & output parameter:
Query table VEPFUNCST with VEPNAME = my web service name, I can find one generated simple transformation:
we can view its content via tcode STRANS:
How to debug the web service call
In case your word document content is not correctly filled by web service, you have to configure out whether it is caused by any issue of the web service provider implementation itself ( in my example it is CL_CRM_PRODIL method GET_OBJECTS ) , or there is another possiblity that the data is correctly returned by the service provider, but lost or conrupt during web service framework processing for example output parameter mapping. You can debug to find the root cause.
The entry point is the Office integration handler class CL_OI_HANDLER to handle with the http request:
You can set breakpoint on the generated read function module to check whether the call is successfully delegated to the service provider – Genil component implementation class’ GET_OBJECTS method:
Then check whether the response returned by service provider is correctly processed by framework via transformation:
Enhance the value assignment via BAdI Implementation
Sometimes the standard processing of Web service framework might not work exactly as what you expect. Take product application for example, Suppose you drag the field UPNAME into word document, and through debugging you can confirm that its content is correctly returned by Genil implementation class, but discarded by framework in method clear_attributes in line 49:
Since the Product application marks field UPNAME as HIDDEN field, so it will be cleared in the final web service output structure:
However if your business scenario does need all hidden fields to be also filled, you can create a BAdI implementation based on enhancement spot CRM_WST_RT_ENHANCEMENT. Specify your web service name as Filter value for SERVICE_NAME.
The BAdI implementation is called AFTER framework processing, so now you have the chance to fill any empty fields all by yourself, since all relevant context are available in changing parameter OUTBOUND.
For a detailed step by step how to do this, please read this document How to enhance a web service response structure in word template integration.
Create the attachment as PDF format
see this document for detail.
Further reference
(1) consulting note 2023246 – Table not showing correct data in attachment created with template
(2) consulting note 2047113 – How to check whether a field in word template is filled correctly by web service
(3) consulting note 2047259 – Trouble shooting guide about word document merge with web service
(4) consulting note 2048272 – A simulation tool to check document template merge issue
(5) consulting note 2055197 – If you would like to know how a word template is merged with data from xml file, you can find technical detail in this document Understand how the word template is merged with xml data stream.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2721604/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAP CRM如何建立支援Web Service的PDF模板Web
- 如何在SAP CRM裡建立和消費Web serviceWeb
- 如何處理SAP CRM Web Service錯誤 - Virtual Interface Method XXXX not supportedWeb
- 如何讓你的SAP CRM應用支援附件上傳
- 如何使用FastReport.Service.dll建立Web服務ASTWeb
- 最詳細的 SAP ABAP Web Service 建立和消費步驟講解Web
- 如何建立自己的SAP CRM產品主資料search scenario
- 如何在 SAP BTP 上建立以及消費 Business Rule Service
- 使用soapUI消費SAP Cloud for Customer的web serviceUICloudWeb
- 如何處理消費SAP ABAP Web Service時遇到的Unauthorized錯誤WebZed
- 使用nodejs消費SAP Cloud for Customer上的Web serviceNodeJSCloudWeb
- 在Google的GKE上建立支援Internal Load Balancer的ServiceGo
- SAP CRM settype的建立,背後發生了什麼
- SAP CRM note建立按鈕被禁用的原因分析
- 如何使用程式碼建立和讀取 SAP CRM 訂單的 Text 資料
- 如何用SAP WebIDE的Fiori建立嚮導基於ABAP OData service快速建立UI5應用WebIDEUI
- SAP CRM WebClient UI 支援的一些 url 引數WebclientUI
- Hybris service layer和SAP CRM WebClient UI架構的橫向比較WebclientUI架構
- Springboot如何利用模板,快速生成word文件?Spring Boot
- docxtpl - word模板
- 如何使用SAP CRM Marketing Survey建立一個市場問卷調查
- CRM的行程支援是如何實現的?行程
- 使用Fiori Elements建立的SAP UI5應用,如何支援編輯功能UI
- SAP不同的產品是如何支援使用者建立自定義欄位的
- 如何修改word預設模板(Normal.dotm)ORM
- SAP ABAP OData 服務如何支援建立(Create)操作試讀版
- 如何監聽SAP CRM BOR事件事件
- 自定義 Word 模板
- Vue 自定義富文字編輯器 tinymce 支援匯入 word 模板Vue
- 如何使用ABSL程式碼呼叫Web serviceWeb
- Android中的Web ServiceAndroidWeb
- 使用ABAP程式碼給SAP CRM Business object建立附件AttachmentObject
- 如何在 SAP BTP 平臺 ABAP 程式設計環境裡消費基於 SOAP 的 Web Service程式設計Web
- 建立windows serviceWindows
- 給 SAP BTP 建立的 Java 應用新增 Custom Event Handler 支援建立功能Java
- 如何選擇Web前端模板引擎?Web前端
- 如何選擇 Web 前端模板引擎?Web前端
- 如何在Kubernetes裡建立一個Nginx serviceNginx