Learn how to design and connect Microsoft document templates to an SAP ERP HCM or SuccessFactors system in a hybrid environment. Once in SAP ERP HCM or SuccessFactors, learn how to use background tasks for mass production of documents.
Key Concept
There are a variety of third-party tools available as macro-enabled add-ons that bridge the gap between Microsoft Word and SAP and SuccessFactors systems, and allow users to generate readable and easy-to-use Microsoft Word documents in an SAP/SuccessFactors hybrid solution. Using a generic method, users can merge the attributes of each environment to produce more useful documents.
Most people are familiar with Microsoft Word and its capabilities for creating, formatting, and editing documents. I show how to generate Microsoft Word documents using an SAP server in SAP ERP HCM or in a hybrid environment using SAP ERP and SuccessFactors. These .xml open standard file options are changing the way Microsoft Office documents are generated, formatted, and used in SAP ERP HCM and SuccessFactors.
The introduction of cloud technologies and mobility are dramatically changing how companies use electronic documents (e.g., any electronic media content other than computer programs or system files that are intended to be used in either an electronic form or as printed output). These new technologies, in turn, affect how Microsoft Word is used, and the new formats change the way documents are generated, read, and manipulated. Using an SAP server as a document server in a hybrid environment is a huge step in this strategy, and it takes document handling to a new level.
Connecting Microsoft Office to an SAP ERP HCM System
Microsoft Word is the best-known word processing software in the world. With over 1 billion users, that means that one in seven people on the planet is using Microsoft Word at any given time. In the organizational world, SAP is often used as the back office system and Microsoft Office is used to move data between employees’ customers and suppliers. For this reason, I am using this functionality as my example scenario in this article.
In the HR area there is a need to correspond with employees, usually using Microsoft Word as the container of data. There are many reasons for this, including the ease of use of Microsoft Word and the need for interactivity of documents, among others.
The SAP solution for connecting Microsoft Word and SAP systems is Microsoft Office integration, also known as Desktop Office Integration (DOI). DOI is based on the old Object Linking and Embedding (OLE) technology and is very limited. It must run on a desktop, it’s very slow and unstable, and can only handle one document at a time.
In the next sections I review the new technology for handling the integration of SAP and Microsoft Office, which is better suited for the new Microsoft Office environment, including cloud computing and mobility.
The New Technology for Integrating SAP and Microsoft Office
Microsoft Office was originally designed to run on a desktop server side generation, also known as the server side automation of Microsoft Office. Documentation for this is hard to find, and there are a lot of problems with Microsoft Office server side generation. My goal here is to clear up some of this confusion.
Today, with the new types of Microsoft Office files, such as .docx for Microsoft Word and .xlsx for Microsoft Excel, there is the ability to create Microsoft Word documents on the server side. For example, if you’re familiar with Microsoft Office 365 Cloud Service, that’s one of the new implementation options for this technology.
Basically, server-side creation of Microsoft Office is based on open standards. That means that if you know the schema of a document it can be manipulated without the need for a dedicated software—in this case, Microsoft Word software. There are three steps for generating server-side documents:
- Design the document
- Select the document data source
- Bind the data source and the document
In the next section I show how these steps are performed on an SAP system to generate useful Microsoft Word documents.
Designing a Microsoft Word Document to be Used in SAP ERP HCM
Here I show how to declare and generate Microsoft Office documents on an SAP server. In this example, I generate a document in SAP ERP HCM based on HR data that should be linked to placeholders in the Microsoft Office document.
First, I create a template using Microsoft Word. The template contains some basic data for an employee and also has a placeholder for the employee image (Figure 1). Open a new Microsoft Word document and enter your text, including headers and footers, if so desired. The next step is to add some content controls that are used to connect external data with the document.

Figure 1
The Microsoft Word template with placeholders for content
There are a few different types of content controls. You can add them navigating to Content Controls from the Developer tab and then go to the Controls group. Click each content control that you wish to add to add it. In this example, I use plain text to add the controls for text. Note that you use the content controls functionality only from Microsoft Office 2007 and up, and make sure you save the file as a .docx file when you save it.
The content controls are placeholders for data sources. In Figure 2 you can see how to navigate to the data controls under the Developer tab in the Controls group.

Figure 2
Navigate to Controls under the Developer tab
Now that you’ve created the new Microsoft Word template, you need to do one more thing before moving it into the SAP system. Each content control can be tagged using an .xml tag so that the process of binding the data source to the fields can be completed. In the ribbon in Figure 2, click Design Mode under the Developer tab. This opens the screen in Figure 3 where you can see the tagged values.

Figure 3
The tagged content controls
The next step is to create this document and its attributes in the SAP environment as a customizing object in SAP. In this example, I’m using an open-standards-based third-party tool for generating Microsoft Office documents in an SAP system. There are a variety of macro-enabled third-party tools available for doing this.
The document customizing screen shown in Figure 4 declares a template to be used to generate the form documents. The first step is to import the Microsoft Word file that you created earlier as your document template into the SAP system. Because this example does not use any tables, you only need to use the Word Content Controls section at the bottom of the screen (if your form had tables, you can’t use Content controls for this step).

Figure 4
Create a Word document template in an SAP system
Here you can see some of the tags used in the Microsoft Word file; all you have to do is bind every tag with its value in the SAP system. I don’t go into detail here about the bits and bytes of the technical issue—my focus is on the process. The steps for creating customized data for a template in an SAP system here is based on the same principle as customizing any SAP document in any SAP environment. This infrastructure is for connecting SAP data with Microsoft Word documents.
The next step is to select the data source and the run-time binding. You can use some ABAP code that can be deployed by any run-time object like program, function module, Business Application Programming Interface (BAPI), and class for those of you who get nervous when you hear the word code. In this case, this is a really simple cut-and-pasteable piece of code to use. You just have to change the data objects in it and you may extend it by using API options.
A brief word about the employee photo in the document. In this example, I used .jpg files on a dedicated directory to store employees’ pictures. There should be no issues with importing employee photos from any data source as long as they are in a common file format, such as .jpg or .jpeg.
Also, you do not need to use the SAP guided user interface (GUI) to run the generation process nor do you need Microsoft Word, so you can run it anytime, anywhere. For example, you can run it as a batch process, from a Business Add-In (BAdI) and user exit, from your portal, or as a Remote Function Call, just to name a few examples.
At this point, you have created a nice template in Microsoft Word, loaded it into the SAP system, and made the connection between the document and the data source. The last step of the process is to create the data-source selection and the run-time binding. As I noted before, you do this using a piece of ABAP code that comes with whatever add-on tool you’re using.
The output document is shown in Figure 5. Here you can see that the content control functionality pulled the data from the SAP system, the employee picture placeholder (e.g., the picture content control) is populated with the correct picture, and the rest of the data is filled in correctly (e.g., First Name, Last Name, and so on).

Figure 5
The actual output of the document using the new template, with the new data
Creating a SuccessFactors and Microsoft Word Template for a Hybrid Environment
The processes for creating and connecting Microsoft Word templates in SuccessFactors are the same as with any other SAP system, with one slight difference.
In an SAP system the data sources are created and connected using the data dictionary and selection method. When using SuccessFactors, the source for the data are the records in Employee Central. Then, using SAP Process Integration (PI), you can create a web service that is used by the SAP system to generate Microsoft Word documents.
In the selection method step you call a web service to get data from SuccessFactors. Then you can use this data, which is stored in the SAP Data Dictionary, the same way you did using the old method in the SAP system. SAP now provides good support to connect to SuccessFactors using PI integration. Although this example uses an SAP ERP HCM system to illustrate how to use Microsoft Word templates, the same functionality is available in all SAP systems and also for every external system that supports web services.
Ronen Almog
Ronen Almog has 18 years of experience in SAP development and consulting and was a Senior Member of SAP projects and products for SAP. Currently, he is the founder of Ox4Sap.
You may contact the author at ronen@openxml4sap.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.