Last month, i published my abstraction class to manage Word OLE link. It can generate complete (and complex) word document, but it is a little slow for big tables.
OLE is an old technology… DOCX is an XML file extension… Enough to change my mind about word file generation. Exit OLE, welcome XML 🙂
I updated my abstraction class to generate DOCX file from ABAP directly, without any OLE usage. I know there are actually some projects that want to do that (abap2docx for example). But i think theses projects are too complex to use, or not yet usable in the true life.
With my class, it never be easier to generate DOCX. You never have to use or understand XML.
Here is the code of the “hello word” program.
The class is simple, but can manage complex documents !
Here is the feature list :
- Empty document creation or with use of template (docx, dotx, docm, dotm)
- Write text with or without style (character style and/or paragraph style)
- Option to manualy apply bold, underline, italic, strike, subscript, superscript, small caps, font name & size, font color, highlight color, letter spacing
- Management of alignment, indent, spacing before/after paragraph
- Break line, page, section, continuous section
- Write table with or without style (and option to define cell format : bold, color…)
- Write Header / footer
- Write end note / foot note
- Write comments
- Write numbered label (figure, table…)
- Write table of labels (figures, tables…)
- Choose portrait/landscape, manage page border
- Add images
- Add canvas
- Insert table of content (toc)
- Add and manage document properties
- Create and insert custom fields
- Style creation (character/paragraph)
- Manage files in SAP Web Repository for template/image (SAPWR, access with transaction SMW0)
In the download file, you will find a test program that contain the class CL_WORD and a demo of how to use it. You will find also some images and 1 template. Theses files are used by the test program, but are not necessary for the class itself.
French presentation can be found here : SAP : Générer un document Word DOCX en ABAP
And there is a direct download link (remember that you will need SAPLINK to install .slnk file) : http://quelquepart.biz/telechargements&file=L2RhdGEvbWVkaWFzL1pDTF9XT1JEX0RPQ1guemlwKjU1NGMxNQ&source=SCN-DOCX
A use case of the class can be found in ZAUTODOC : Automatic generation of technical BW documentation
Last but not the least, source code is visible here : Show code in Nugget – Quelquepart
Feel free to comment here 🙂
My others blogpost :