如何创建能够支持Web Service的Word文档-阿里云开发者社区

开发者社区> jerrywangsap> 正文

如何创建能够支持Web Service的Word文档

简介: 如何创建能够支持Web Service的Word文档
+关注继续查看

In these two documents below, I have demonstrated the steps how to create word or PDF document as attachments which could consume web service created via CRM web service tool.


(1) Create Webservice enabled Adobe PDF attachment in CRM Application

(2) Create Webservice enabled word document in attachment assignment block


As we could find in document template creation UI, there is a third option which allows us to assign a WSDL URL of an external web service to a document template. So this document will explain how to create a word template which could consume your own web service, instead of the one created via CRM web service tool.


image.png


Ensure you have a working web service

for simplicity I just create a simple function module which do the add operation and expose it into web service with tcode SOAMANAGER.


image.png


In order to consume it, An ABAP proxy is needed.

Test the ABAP consumer proxy in ABAP workbench and make it work, since it will be used later:



image.png


You could use this document as reference about how to expose a function module into web service via SOAMANAGER and the necessary configuration to consume it in ABAP.


Create word template and assign your web service WSDL to it

In document creation UI, choose radio box “Own WSDL URL”, paste your web service WSDL URL to input field and press entry key, then your web service operation will appear in drop down list automatically. Choose your operation and click button “Start Designer”.

If you meet with 401 unauthorization error message after enter key is pressed, refer to this document about solution:


How to resolve Unauthorized error message when defining external web service for document template


image.png


Now a new word document is opened. You could drag the output variable EV_RESULT from SAP Data panel to your word body area.

Its content will be filled by your web service in the runtime. Finish the template development.


image.png


Implement BAdI to consume the web service

Create a BAdI implementation via the customizing activity below:


image.png


You could refer to my implementation code below:

image.png

line 17: Create an instance of ABAP consumer proxy class.

line 21: The current business object instance GUID is included in importing parameter IS_OBJECT-INSTID.

Since my word template is created based on BOR type BUS1178, so I could directly query product database table COMM_PRODUCT to

find the corresponding product record.


line 24 ~ 27: I just fetch the valid from timestamp of current product and pass the date value to the first importing parameter of web service call. The second importing parameter is assigned with 0, so in the final word document we will see the valid from date of current product.


line 28: execute web service call, the result is included in parameter ls_output.

line 38 and 39: pass out the web service response payload to changing parameter, which will be used by Office integration framework to merge with word template.


image.png

Test in UI

Now you could create attachment based on your word template by clicking button “With Template”. Choose the word template you have just developed from pop up window:


image.png


you could still set breakpoint in your BAdI implementation and the function module exposed as web service to observe how they are consumed in the runtime:


image.png



Finally the web service calculation result is displayed in the word document.


image.png


Further reading

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.



版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
使用SAP portal service创建Fiori Launchpad
使用SAP portal service创建Fiori Launchpad
14 0
Android官方开发文档Training系列课程中文版:连接无线设备之通过WIFI创建P2P连接
原文地址:http://android.xsoftlab.net/training/connect-devices-wirelessly/wifi-direct.html#permissions Wi-Fi peer-to-peer (P2P) APIs可以使程序与附近的设备进行直接通讯,Android的Wi-Fi P2P框架由Wi-Fi Direct™提供技术支持。
758 0
[ASP.NET]二维码的创建
又好一段时间没有写写东西了,继续回归原来的模式,多做记录,最近要实现个unity的二维码方面的功能,首先就要解决生成二维码的问题,这个倒是有这方面的组件,然后我通过强大的反编译工具Reflector(想必.NET程序都知道的神器),来插件内部实现的原理。
903 0
在word文档里提取出所有的邮箱地址
怎样在word文档里提取出所有的邮箱地址 文档内容太多,邮箱也有很多,一个个复制粘贴太浪费时间,怎样把这些邮箱简单的提取出来  答案:用查找功能。 查找目标:[A-z,0-9]{1,}\@[A-z,0-9,\.]{1,} 查找全部即可一次性选中。 如图操作:
801 0
如何在Kubernetes里创建一个Nginx service
Jerry之前的文章如何在Kubernetes里创建一个Nginx应用,已经使用kubectl命令行创建了Pod,但是在kubernetes中,Pod的IP地址会随着Pod的重启而变化,因此用Pod的IP地址来访问我们部署的nginx应用不太合适。
1972 0
如何在SAP CRM里创建和消费Web service
Created by Wang, Jerry, last modified on Dec 19, 2014 The following steps demonstrates how to expose a function module as a web service in CRM.
1339 0
+关注
2628
文章
0
问答
来源圈子
更多
+ 订阅
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载