Integrating SAP Document Builder and Microsoft SharePoint 2010

handsgridServers

Dec 4, 2013 (3 years and 9 months ago)

102 views

1


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 Do
cument 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# we
b 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 website
s, 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


2


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.


SharePoint’s support of (a)
document management

and (b)
Word server capabilities

(e.g. PDF
conversion)

mak
e 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 docum
ents 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 docum
ent management needs.



PDF conversion


the best (and

prior to SharePoint 2010, the

only) enterprise solution has been
to integrate Document Builder with Adobe’s Livecycle system.


Although t
hese solutions to the document management and PDF conversion need
s

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.



3


Landscape
s

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 BADI’s 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 Docum
ent 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 configuration
s

of Document Builder/SharePoint landscapes and sc
enarios.


Typical Document Builder / Livecycle landscape and scenario


Document
Builder
SRM
Livecycle
1
2
3
4



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.





4


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


Document
Builder
SRM
SharePoint
1
2
3
4


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. (Ne
ither 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.




5


Document Builder / SharePoint Landscape:
PDF conversion and document management


Document
Builder
SRM
Livecycle
1
2
3
4


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 SharePoin
t to

SRM.




6


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


Document
Builder
SharePoint
2
3
1

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.




7


Document Builder / SharePoint / Livecycle Landsca
pe:
document management only


Document
Builder
SRM
Livecycle
1
2
3
6
SharePoint
4
5


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 Shar
ePoint library) to Document
Builder.

6.

Document Builder returns
a

URL to

compound PDF document in SharePoint to

SRM.



8


Technical Architecture of Document Builder/SharePoint Integration

This section presents the technical architecture for a Document Builder/S
harePoint 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
Output BADI for
Word document
Microsoft Windows
Server
SharePoint
2010
Document
Builder
/
SharePoint self
-
hosted web
service

The output BADI for the document communica
tes 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
s
erver hosted by SharePoint.

The Document Builder/SharePoint web service was developed in .NET 4/C# using Microsoft’s 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 st
art up when
the Windows server is booted. It is
thread
-
safe

in that multiple concurrent ins
tances 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.



9


Document Builder/SharePoint Web Service Code

The web service (described above) has been implemented and tested in a Document Builder
environme
nt. (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.



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. This would simplify the startup/showdown steps for the web service.



The web service could be ext
ended 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 (L
CA).



Beyond SharePoint, this web service could be re
-
architected to allow cloud
-
based document
management capabilities for Document Builder.




11


Appendix A


Document Builder/SharePoint C# web service client code


using

System;

using

System.Collections.Gene
ric;

using

System.Linq;

using

System.Text;

using

SharePointClient.ServiceReference1;

using

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.
SharePointSVCClie
nt

client =


new

SharePointSVCClient
();



try


{


byte
[] pdf = client.ConvertToPDF(data,


"test"
,


"Shared D
ocuments"
,


" "
,


" "
,


"PDF"
);


}


catch

(
Exception

e)


{


Cons
ole
.WriteLine(e.Message);


}


}


}

}




12


Here’s 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
>




13


Appendix B


Document Builder/SharePoint ABAP web service client code


*&
---------------------------------------------------------------------
*

*&

Report

ZSK_SHAREPOINT_CLIENT

*&

*&
---------------------------------------------------------------------
*

*&

*&

*&
--------------------------------------------------------------------
-
*


REPORT

zsk_sharepoint_client

LINE
-
SIZE

1000
.


DATA

lo_sharepoint

TYPE

REF

TO

zxco_ishare_point_svc
.

DATA

ls_input

TYPE

zxishare_point_svc_convert_to1
.

DATA

ls_output

TYPE

zxishare_point_svc_convert_to
.

DATA

lo_sys_exc

TYPE

REF

TO

cx_ai_system_fault
.

DATA

lo_app_exc

TYPE

REF

TO

cx_ai_application_fault
.

DATA

lv_exception_msg

TYPE

string
.

DATA

lx_word

TYPE

xstring
.


DATA

lv_filename

TYPE

string
.

DATA

lv_text_xstring

TYPE

xstring
.

DATA

lv_text_string

TYPE

string
.

DATA

lv_text_base64

TYPE

string
.

DATA

lv_ret

TYPE

string
.

DATA

lv_file_type

TYPE

c
.




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'
.

14



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

dow
nload_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_tex
t_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

15



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
.

16


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