Sie sind auf Seite 1von 16

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 Microsofts 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

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

Landscapes
Document Builder produces its document output using an output BADI. Customers typically copy the distributed BADI code and make the necessary changes. It is the BADIs job to build the Word document and hand it off to the host system for document management. If PDF conversion prior to hand off is required, then the Document Builder output BADI code communicates with, say, Livecycle. In this section a typical Document Builder/Livecycle landscape and scenario is presented, along with several different configurations of Document Builder/SharePoint landscapes and scenarios. Typical Document Builder / Livecycle landscape and scenario

SRM

Document Builder

Livecycle

1. Document Builder is launched from SRM. Document Builder builds Word document and form. 2. Document Builder sends Word document and form to Livecycle. Livecycle (a) converts Word to PDF, and (b) puts PDF document and form together. 3. Livecycle returns compound PDF (document + form) to Document Builder. 4. Document Builder stores PDF in SRM as attachment to SRM business object.

Document Builder / SharePoint Landscape: PDF conversion only, no document management

SRM

Document Builder

SharePoint

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

Document Builder / SharePoint Landscape: PDF conversion and document management

SRM

Document Builder

Livecycle

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

Document Builder / SharePoint Landscape: standalone launch, PDF conversion and document management

2 1 Document Builder

SharePoint

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

Document Builder / SharePoint / Livecycle Landscape: document management only

2 1

Livecycle

3 SRM Document Builder 4

6 5 SharePoint

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

Technical Architecture of Document Builder/SharePoint Integration


This section presents the technical architecture for a Document Builder/SharePoint solution. Note: other than slight changes to the Document Builder output BADI software, the following architecture supports all of the SharePoint scenarios presented above.

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. (More on this web service below.) The web service, in turn, communicates with (1) SharePoint library services and (2) the Word server hosted by SharePoint. The Document Builder/SharePoint web service was developed in .NET 4/C# using Microsofts Visual Studio 2010 and the Windows Communication Framework (WCF). 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. To start the web service, simply start the web service self-host program. This program has a console that reports web service activity. The web service program can be configured to start up when the Windows server is booted. It is thread-safe in that multiple concurrent instances of the web service can run without conflicts. Based on capacity of the Windows server and the performance/workload of SharePoint, the web service is scalable. The web service program is installed on the Windows server using standard Windows software installation tools.

Document Builder/SharePoint Web Service Code


The web service (described above) has been implemented and tested in a Document Builder environment. (For information about the source code and other web service details, please contact skeyes42@gmail.com.)

Document Builder/SharePoint Web Service Console


When the web service starts, it looks like this:

After a successful invocation of the web service, 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.

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. This would simplify the startup/showdown steps for the web service. The web service could be extended to support storing/retrieving any files to/from SharePoint libraries. The web service could be converted from a SOAP-based protocol to a REST-based protocol. For use with Livecycle, this web service would be integrated into a Livecycle application (LCA). Beyond SharePoint, this web service could be re-architected to allow cloud-based document management capabilities for Document Builder.

10

Appendix A Document Builder/SharePoint C# web service client code


using using using using using using System; System.Collections.Generic; System.Linq; System.Text; SharePointClient.ServiceReference1; System.IO;

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.docx"); long numBytes = fInfo.Length; FileStream fStream = new FileStream(@"c:\temp\test.docx", FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fStream); byte[] data = br.ReadBytes((int)numBytes); br.Close(); fStream.Close();

SharePointClient.ServiceReference1.SharePointSVCClient client = new SharePointSVCClient(); try { byte[] pdf = client.ConvertToPDF(data, "test", "Shared Documents", " ", " ", "PDF"); } catch (Exception e) { Console.WriteLine(e.Message); } } } }

11

Heres the associated app.config file:


<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.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.net:8000/SharePointService/Service/SharePointSVC" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISharePointSVC" contract="ServiceReference1.ISharePointSVC" name="BasicHttpBinding_ISharePointSVC" /> </client> </system.serviceModel> </configuration>

12

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. TYPE TYPE TYPE TYPE TYPE TYPE TYPE REF TO zxco_ishare_point_svc. zxishare_point_svc_convert_to1. zxishare_point_svc_convert_to. REF TO cx_ai_system_fault. REF TO cx_ai_application_fault. string. xstring. string. xstring. string. string. string. c.

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. CREATE OBJECT lo_sharepoint. "lv_filename = 'c:\temp\tryit\test.xml'. lv_filename = 'c:\temp\tryit\stuffx_42.xml'. lv_file_type = 'X'. PERFORM load_data_from_file USING lv_filename lv_file_type CHANGING lv_text_string lv_text_xstring lv_text_base64 lv_ret. ls_input-word_doc = lv_text_xstring. ls_input-doc_name = 'tester'. ls_input-target_libray = 'Shared Documents'. ls_input-store_doc = 'X'. ls_input-store_cvt = 'X'.

13

ls_input-output_format = 'docx'. TRY. CALL METHOD lo_sharepoint->convert_to_pdf EXPORTING input = ls_input IMPORTING output = ls_output. CATCH cx_ai_system_fault INTO lo_sys_exc. lv_exception_msg = lo_sys_exc->get_text( ). WRITE lv_exception_msg. CATCH cx_ai_application_fault INTO lo_app_exc. lv_exception_msg = lo_app_exc->get_text( ). WRITE lv_exception_msg. ENDTRY. lv_filename = 'c:\temp\tryit\tester.docx'. PERFORM download_document USING ls_output-convert_to_pdfresult lv_filename. WRITE: / 'done'. *&---------------------------------------------------------------------* *& 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. DATA lt_data TYPE swxmlcont. DATA lv_ret LIKE sy-subrc. DATA lx_data TYPE xstring. DATA lv_data TYPE string. DATA lv_size TYPE i. DATA lo_converter TYPE REF TO cl_abap_conv_in_ce. ev_ret = 'success'. CLEAR lt_data. CALL METHOD cl_gui_frontend_services=>gui_upload

14

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. IF NOT sy-subrc = 0. ev_ret = 'failure'. RETURN. ENDIF. 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. IF NOT sy-subrc = 0. ev_ret = 'failure'. RETURN. ENDIF. CASE iv_file_type. WHEN 'X'. "xstring RETURN. WHEN 'S'. "string lo_converter = cl_abap_conv_in_ce=>create( ). lo_converter->convert( EXPORTING input = ev_text_xstring IMPORTING data = ev_text_string ). RETURN. WHEN 'B'. "base64 CALL FUNCTION 'SSFC_BASE64_ENCODE' EXPORTING bindata = ev_text_xstring binleng = lv_size IMPORTING b64data = ev_text_base64. RETURN. ENDCASE.

15

ENDFORM. "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. DATA lt_data TYPE swxmlcont. DATA lv_len TYPE i. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = iv_xtext IMPORTING output_length = lv_len TABLES binary_tab = lt_data. * Download the binary PDF from the binary table. CALL METHOD cl_gui_frontend_services=>gui_download EXPORTING bin_filesize = lv_len filename = iv_filename filetype = 'BIN' CHANGING data_tab = lt_data. ENDFORM. " download_document

16

Das könnte Ihnen auch gefallen