Integrating SAP Document Builder and Microsoft SharePoint 2010

Steve Keyes April 2012

Contents
Integrating SAP Document Builder and Microsoft SharePoint 2010 ............................................................ 1 Introduction .............................................................................................................................................. 1 Landscapes ................................................................................................................................................ 3 Typical Document Builder / Livecycle landscape and scenario ............................................................ 3 Document Builder / SharePoint Landscape: PDF conversion only, no document management ......... 4 Document Builder / SharePoint Landscape: PDF conversion and document management ................ 5 Document Builder / SharePoint Landscape: standalone launch, PDF conversion and document management ......................................................................................................................................... 6 Document Builder / SharePoint / Livecycle Landscape: document management only........................ 7 Technical Architecture of Document Builder/SharePoint Integration ..................................................... 8 Document Builder/SharePoint Web Service Code.................................................................................... 9 Document Builder/SharePoint Web Service Console ............................................................................... 9 Possibilities for the Document Builder/SharePoint Web Service ........................................................... 10 Appendix A – Document Builder/SharePoint C# web service client code .............................................. 11 Appendix B – Document Builder/SharePoint ABAP web service client code ......................................... 13

Introduction
Microsoft SharePoint is Microsoft’s portal software. It allows users to build and publish websites, it offers structures and tools (lists, libraries, etc.) for managing documents, and -- new with the 2010 release -- SharePoint provides Word server capabilities. SharePoint 2010 lets developers build web services that can access and perform programmatic, server-side functions, including:    Automatic conversion of Word (.doc, .xml, .docx) to PDF Automatic expansion of fields, including table of contents fields Storage and retrieval of documents to and from SharePoint libraries

1

customers have used Records Management to meet more complex document management needs.In other words. Although these solutions to the document management and PDF conversion needs are functional. SharePoint’s support of (a) document management and (b) Word server capabilities (e. e. The focus of this document is to present a solution that takes care of simple document management and PDF conversion. these two needs (document management and PDF conversion) have been handled as follows:  Document management – Document Builder documents are attached to MM or SRM business objects as attachments. It is assumed that the host system would take care of document management needs. say. It also discusses other possible extensions to the integrated solution. budget management. PDF conversion) make it a good candidate for integration with Document Builder. SharePoint 2010 lets you operate Word and SharePoint (under program control) as if you were using Word or SharePoint on your laptop. In addition. SRM. audit management. sometimes miss key customer requirements:  Many Document Builder customers are also existing SharePoint customers. Document Builder was designed to build these documents then hand off the output to the host system. This document presents a strategy for integrating Document Builder and SharePoint 2010.g. as well as. etc. Document Builder builds Word documents – ranging from simple boilerplate documents to complex structured documents with fill-ins. MM.g. To date. These customers use SharePoint for enterprise document management.  PDF conversion – the best (and prior to SharePoint 2010. the only) enterprise solution has been to integrate Document Builder with Adobe’s Livecycle system. converting Word to.  Some smaller Document Builder customers do not have the budget to afford a Livecycle solution or Records Management consulting. and would like Document Builder documents to be a part of their SharePoint portal. 2 . Off-the-shelf. PDF.

Livecycle. In this section a typical Document Builder/Livecycle landscape and scenario is presented. Document Builder builds Word document and form. Document Builder stores PDF in SRM as attachment to SRM business object. 4. say. 3 . Document Builder is launched from SRM. Typical Document Builder / Livecycle landscape and scenario 1 2 SRM Document Builder Livecycle 4 3 1. Livecycle (a) converts Word to PDF. Document Builder sends Word document and form to Livecycle. Customers typically copy the distributed BADI code and make the necessary changes. If PDF conversion prior to hand off is required.Landscapes Document Builder produces its document output using an output BADI. 3. It is the BADI’s job to build the Word document and hand it off to the host system for document management. Livecycle returns compound PDF (document + form) to Document Builder. along with several different configurations of Document Builder/SharePoint landscapes and scenarios. then the Document Builder output BADI code communicates with. and (b) puts PDF document and form together. 2.

2.Document Builder / SharePoint Landscape: PDF conversion only. SRM launches Document Builder and Document Builder builds a Word document. SharePoint returns the PDF document to Document Builder.) 3. (Neither the Word document or the generated PDF document are stored in SharePoint. no document management 1 2 SRM Document Builder SharePoint 4 3 In this scenario: 1. 4. 4 . Document Builder sends the Word document to SharePoint for PDF conversion. Document Builder returns the PDF document to SRM for document management.

3. 5 . 4. SRM launches Document Builder and Document Builder builds a Word document. The Document Builder Word document and the new PDF document are stored in a SharePoint library. and (b) storage. SharePoint returns a URL to the PDF document (in the SharePoint library) to Document Builder.Document Builder / SharePoint Landscape: PDF conversion and document management 1 2 SRM Document Builder Livecycle 4 3 In this scenario: 1. 2. Document Builder sends the Word document to SharePoint for both (a) PDF conversion. Document Builder returns the URL to the PDF in SharePoint to SRM.

PDF conversion and document management 2 1 Document Builder SharePoint 3 In this scenario: 1. SharePoint returns a URL to the PDF document (in the SharePoint library) to Document Builder. and (b) document storage.Document Builder / SharePoint Landscape: standalone launch. 3. The user launches Document Builder standalone and builds the Word document. 6 . Document Builder sends the Word document to SharePoint for both (a) PDF conversion. 2.

5. Document Builder returns a URL to compound PDF document in SharePoint to SRM. 7 . Document Builder sends the compound PDF to SharePoint for document management.Document Builder / SharePoint / Livecycle Landscape: document management only 2 1 Livecycle 3 SRM Document Builder 4 6 5 SharePoint In this scenario: 1. 3. Livecycle (1) converts the Word to PDF and compounds the PDF document with the form. 2. 4. SRM launches Document Builder. Document Builder sends the Word document and PDF form to Livecycle. Document Builder builds a Word document and form. SharePoint returns a URL to the compound document (in a SharePoint library) to Document Builder. 6. Livecycle sends the compound PDF back to Document Builder.

) The web service. To start the web service. simply start the web service self-host program. the web service is scalable. Document Builder Microsoft Windows Server SharePoint 2010 Output BADI for Word document Document Builder/ SharePoint selfhosted web service The output BADI for the document communicates with a Document Builder/SharePoint self-hosted web service that runs on the same Windows server that hosts SharePoint 2010. The Document Builder/SharePoint web service was developed in . communicates with (1) SharePoint library services and (2) the Word server hosted by SharePoint. Note: other than slight changes to the Document Builder output BADI software. Based on capacity of the Windows server and the performance/workload of SharePoint.NET 4/C# using Microsoft’s Visual Studio 2010 and the Windows Communication Framework (WCF). The web service program is installed on the Windows server using standard Windows software installation tools. (More on this web service below. It is thread-safe in that multiple concurrent instances of the web service can run without conflicts. the following architecture supports all of the SharePoint scenarios presented above. in turn. 8 .Technical Architecture of Document Builder/SharePoint Integration This section presents the technical architecture for a Document Builder/SharePoint solution. This program has a console that reports web service activity. It is a self-hosted web service meaning that the web service code has its own initialization and support code and does not require Microsoft IIS. The web service program can be configured to start up when the Windows server is booted.

the console looks like this: The web service program console output can be re-directed to a log file to have a permanent record of the web service activity. (For information about the source code and other web service details.) Document Builder/SharePoint Web Service Console When the web service starts. please contact skeyes42@gmail.Document Builder/SharePoint Web Service Code The web service (described above) has been implemented and tested in a Document Builder environment.com. 9 . it looks like this: After a successful invocation of the web service.

Beyond SharePoint. this web service could be re-architected to allow cloud-based document management capabilities for Document Builder. This would simplify the startup/showdown steps for the web service. this web service would be integrated into a Livecycle application (LCA). For use with Livecycle. The web service could be extended to support storing/retrieving any files to/from SharePoint libraries. 10 .Possibilities for the Document Builder/SharePoint Web Service Here are some future extensions the web service presented in this document:      The web service could be converted from a self-hosted WCF web service to a service-type WCF web service. The web service could be converted from a SOAP-based protocol to a REST-based protocol.

Close().docx").Read). BinaryReader br = new BinaryReader(fStream). long numBytes = fInfo.Length. " ".docx".ServiceReference1. namespace SharePointClient { class Program { static void Main(string[] args) { // Read test.docx file from file system into data[] FileInfo fInfo = new FileInfo(@"c:\temp\test.Text. " ". byte[] data = br. System. "Shared Documents".ReadBytes((int)numBytes). "test". SharePointClient. fStream. System.Collections. SharePointClient.Message).Linq.Generic.Close(). } } } } 11 . System.IO. br.WriteLine(e. try { byte[] pdf = client. FileStream fStream = new FileStream(@"c:\temp\test.Appendix A – Document Builder/SharePoint C# web service client code using using using using using using System. FileMode.ConvertToPDF(data.Open. } catch (Exception e) { Console. "PDF"). System.SharePointSVCClient client = new SharePointSVCClient(). FileAccess.ServiceReference1.

ISharePointSVC" name="BasicHttpBinding_ISharePointSVC" /> </client> </system.serviceModel> </configuration> 12 .serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_ISharePointSVC" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="20000000" maxBufferPoolSize="524288" maxReceivedMessageSize="20000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="20000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://keyes42.does-it.config file: <?xml version="1.Here’s the associated app.net:8000/SharePointService/Service/SharePointSVC" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISharePointSVC" contract="ServiceReference1.0" encoding="utf-8" ?> <configuration> <system.

ls_input-target_libray = 'Shared Documents'. TYPE TYPE TYPE TYPE TYPE TYPE TYPE REF TO zxco_ishare_point_svc.xml'. c. string. string. ls_input-doc_name = 'tester'. "lv_filename = 'c:\temp\tryit\test. CREATE OBJECT lo_sharepoint. xstring. lo_sharepoint ls_input ls_output lo_sys_exc lo_app_exc lv_exception_msg lx_word lv_filename lv_text_xstring lv_text_string lv_text_base64 lv_ret lv_file_type TYPE TYPE TYPE TYPE TYPE TYPE START-OF-SELECTION. zxishare_point_svc_convert_to. 13 . string.xml'. xstring. ls_input-store_doc = 'X'. REF TO cx_ai_system_fault. ls_input-word_doc = lv_text_xstring. PERFORM load_data_from_file USING lv_filename lv_file_type CHANGING lv_text_string lv_text_xstring lv_text_base64 lv_ret. REF TO cx_ai_application_fault. string. lv_file_type = 'X'. string. lv_filename = 'c:\temp\tryit\stuffx_42.Appendix B – Document Builder/SharePoint ABAP web service client code *&---------------------------------------------------------------------* *& Report ZSK_SHAREPOINT_CLIENT *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA zsk_sharepoint_client LINE-SIZE 1000. zxishare_point_svc_convert_to1. ls_input-store_cvt = 'X'.

DATA lt_data TYPE swxmlcont. DATA lo_converter TYPE REF TO cl_abap_conv_in_ce. CLEAR lt_data. ENDTRY. TRY. lv_filename = 'c:\temp\tryit\tester. DATA lv_data TYPE string. WRITE: / 'done'. DATA lv_ret LIKE sy-subrc.ls_input-output_format = 'docx'. WRITE lv_exception_msg. WRITE lv_exception_msg. DATA lv_size TYPE i. lv_exception_msg = lo_app_exc->get_text( ).docx'. DATA lx_data TYPE xstring. lv_exception_msg = lo_sys_exc->get_text( ). ev_ret = 'success'. CATCH cx_ai_system_fault INTO lo_sys_exc. CALL METHOD lo_sharepoint->convert_to_pdf EXPORTING input = ls_input IMPORTING output = ls_output. CALL METHOD cl_gui_frontend_services=>gui_upload 14 . CATCH cx_ai_application_fault INTO lo_app_exc. *&---------------------------------------------------------------------* *& Form load_data_from_file *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->IV_FILENAME text * -->IV_FILE_TYPE text * -->EV_TEXT_STRING text * -->EV_TEXT_XSTRING text * -->EV_TEXT_BASE64 text * -->EV_RET text *----------------------------------------------------------------------* FORM load_data_from_file USING iv_filename TYPE string iv_file_type TYPE c CHANGING ev_text_string TYPE string ev_text_xstring TYPE xstring ev_text_base64 TYPE string ev_ret TYPE string. PERFORM download_document USING ls_output-convert_to_pdfresult lv_filename.

CASE iv_file_type. 15 . RETURN. WHEN 'B'. ENDIF. RETURN. IF NOT sy-subrc = 0.EXPORTING filename = iv_filename filetype = 'BIN' IMPORTING filelength = lv_size CHANGING data_tab = lt_data EXCEPTIONS file_open_error = 1 file_read_error = 3 invalid_type = 4 no_batch = 5 gui_refuse_filetransfer = 7 OTHERS = 99. RETURN. CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' EXPORTING input_length = lv_size IMPORTING buffer = ev_text_xstring TABLES binary_tab = lt_data EXCEPTIONS failed = 1 OTHERS = 2. ev_ret = 'failure'. "string lo_converter = cl_abap_conv_in_ce=>create( ). RETURN. lo_converter->convert( EXPORTING input = ev_text_xstring IMPORTING data = ev_text_string ). "xstring RETURN. WHEN 'X'. "base64 CALL FUNCTION 'SSFC_BASE64_ENCODE' EXPORTING bindata = ev_text_xstring binleng = lv_size IMPORTING b64data = ev_text_base64. ENDIF. ev_ret = 'failure'. IF NOT sy-subrc = 0. WHEN 'S'. ENDCASE.

CALL METHOD cl_gui_frontend_services=>gui_download EXPORTING bin_filesize = lv_len filename = iv_filename filetype = 'BIN' CHANGING data_tab = lt_data. DATA lt_data TYPE swxmlcont.ENDFORM. " download_document 16 . "load_data_from_file *&---------------------------------------------------------------------* *& Form download_document *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->IV_XTEXT text * -->IV_FILENAME text * -->ET_DATA text *----------------------------------------------------------------------* FORM download_document USING iv_xtext TYPE xstring iv_filename TYPE string. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = iv_xtext IMPORTING output_length = lv_len TABLES binary_tab = lt_data. ENDFORM. DATA lv_len TYPE i. * Download the binary PDF from the binary table.

Sign up to vote on this title
UsefulNot useful