Open Microsoft Office document in SAP using OPC

A+ A-

Hello.

if my previous post http://scn.sap.com/community/abap/application-development/blog/2013/03/08/what-is-open-xml

i wrote a short description about Open XML standard.

Open XML let us the possibility to read , write and manipulate Open XML (OOXML)  documents.

sounds confusing?

let's explain this.

we want to read Microsoft Word .docx extension into SAP , upload the file and then do some actions on this file.

in the old days we had .doc extension file that was uploaded into SAP and we had no possibility to manipulate the file.

we could only use Office Integration methods or OLE methods

and we had to open Word application to use it.

 

now , with OOXML we have a lot of opportunities.

Open XML files are really ZIP files and not Binary files as the legacy .doc or .xls extensions are.

 

we can see here examples of OPC extensions 

 

opc1.jpg

 

 

let's have an example.

we will create a new Microsoft Word document.

 

 

opc.jpg

 

 

the document contains a header with a logo and some text.

save it as scnExample.docx file.

now, let's change the file extension to .zip.

 

 

opc1.jpg

 

now we have scnExample.docx.zip file.

we will unzip the file

and we got a zip directory contains subdirectories and files.

 

 

opc2.jpg

 

 

this is the structure of the Open Packaging Conventions (OPC) which is a container-file technology.

this is a combination of xml and non xml files that together create an Open XML document.

now , you can understand what's the main difference between legacy and Open XML files.

Open XML let us the freedom to handle the documents as we need on any platform we need.

this is a huge advantage over the old methods that used macros and so on.

 

from here we will upload the file using any method of file uploading into SAP server,

( local file or Read dataset method ).

the file will be inserted into a Zip object in ABAP

and then we could manipulate and handle every part of the ZIP object.

think about in as a puzzle or a Lego.

you break it into pieces ( called parts in  OPC )

handle the pieces you need

and then collect all the pieces into one ZIP object.

 

and more to come...

 

Ronen Almog