Top Banner
Microsoft Content Management Server Integration with SAP Using MCMS Custom Placeholders and the SAP .NET Connector Written by: Bill Olson, Avanade Tom Kirkby, Avanade Published on July 1 st , 2004 Abstract Microsoft Content Management Server (MCMS) 2002 allows authors to quickly create and update content on a Web site, with minimal knowledge of the site architecture or structure, using tasks predefined by a site administrator. Learn how to extend an existing MCMS implementation to deliver SAP content by making use of the SAP .NET Connector and MCMS custom placeholder controls. (34 printed pages)
35

MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

Sep 01, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

Microsoft Content Management Server Integration with SAP Using MCMS Custom Placeholders and the SAP .NET Connector

Written by: Bill Olson, Avanade Tom Kirkby, Avanade Published on July 1st, 2004

Abstract

Microsoft Content Management Server (MCMS) 2002 allows authors to quickly create and update content on a Web site, with minimal knowledge of the site architecture or structure, using tasks predefined by a site administrator. Learn how to extend an existing MCMS implementation to deliver SAP content by making use of the SAP .NET Connector and MCMS custom placeholder controls. (34 printed pages)

Page 2: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

© Microsoft Corporation 2004.

Page 3: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

CONTENTS

INTRODUCTION ...........................................................................................................4 Overview 4 Business Scenario 4 Prerequisites 4

INTEGRATION APPROACH ..........................................................................................6 SAP .NET Connector 7 Extending MCMS 8

CREATING CUSTOM PLACEHOLDERS IN MCMS`........................................................9

INTEGRATING WITH SAP ..........................................................................................12 Step 1: Install the Z_MSSP_GET_PAYROLL_RESULTS RFC into SAP 12 Step 2: Creating the SAP Class Library Project 13 Step 3: Generating the SAP .NET Connector Proxy Class 14 Step 4: Building the User Interface for the Custom Placeholder 17 Step 5: Implementing the Overridden Methods in the Custom Placeholder 25 Step 6: Creating the MCMS Template and Posting to Host the Placeholder 32

DEPLOYMENT CONSIDERATIONS.............................................................................34

CONCLUSION.............................................................................................................35 Related Links 35

Page 4: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 4

INTRODUCTION

Overview

Microsoft® Content Management Server (MCMS) 2002 is an enterprise Web content management system that enables companies to quickly and efficiently build, deploy, and maintain highly dynamic Internet, intranet, and extranet Web sites. MCMS internally stores web pages as instances of custom developed templates. These templates are composed of a series of content placeholders in which authors add or configure content to generate a customized web page. In addition to the standard content placeholders included with MCMS, custom placeholders can be developed which provide authors a custom interface for content generation. When a web page is requested, the page is assembled by combining the appropriate template, placeholders and content. This enables specific content to be reused and served to different devices, audiences, and individuals without complex coding or duplication of effort.

In this white paper, we’ll integrate MCMS web pages with SAP by building a custom placeholder and implementing a Web service proxy client using the SAP .NET Connector. The SAP .NET Connector is an SAP product that provides developers both design time tools and run time libraries for communicating between SAP systems and the Microsoft .NET platform. With the custom placeholder, content authors can easily build web pages that access and display SAP data to customers, business partners, and employees.

Business Scenario

You are the HR manager for the Woodgrove company. Woodgrove has just finished a SAP implementation and senior management wants to take advantage of the new system by integrating it with the existing intranet portal. You want to enable your employees to view their pay stub information and to enable the site editors to easily configure the information displayed using your Microsoft Content Management Server (MCMS) Web site.

Prerequisites

Microsoft® Content Management Server (MCMS) 2002 requires the following minimum system configuration:

Content Server:

Microsoft Windows® 2000 Server, Professional, or Advanced Server and Service Pack 2 or later (Microsoft Windows® XP Professional Service Pack 1 can be used as an alternative to Windows 2000 Server for developing the site, though it should not be used in production)

Microsoft SQL Server™ 2000 and SP2

Microsoft .NET Framework and SP2

Page 5: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 5

Microsoft Internet Information Services (IIS) 5.0 and IIS security hotfix MS02-018

Microsoft Internet Explorer® 6.0 or later

Internet Explorer WebControls v.1.0

Database:

SQL Server 2000

Developer tools:

All server software (Microsoft Windows XP Professional Service Pack 1 can be used as an alternative to Windows 2000 Server)

Microsoft Visual Studio® .NET

Java Runtime Environment (You can download JRE version 1.3 or later from http://java.sun.com/j2se/1.3/jre)

SAP .NET Connector – Information about the SAP .Net Connector available from http://www.microsoft-sap.com/net_connector.aspx (SAP customers and partner can download the SAP .Net Connector from the SAP Marketplace http://service.sap.com/connectors). SAP licensing conditions apply to all users, who connect to an SAP system using the SAP .NET Connector

Page 6: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 6

INTEGRATION APPROACH

In our business scenario, the HR manager needs to extend existing MCMS pages to include SAP pay stub data specific to each employee. In MCMS, web pages are stored as instances of templates, called postings, and specific page content is stored as objects within the MCMS database. Templates are composed of a series of content placeholders which authors use to customize a page. In addition to the standard content placeholders included with MCMS, custom placeholders can be developed to perform customized tasks. When a web page is requested, the page is assembled by combining the appropriate template, placeholders and content. This enables specific content to be reused and served to different devices, audiences, and individuals without complex coding or duplication of effort.

In our solution, we’ll develop a custom placeholder component that integrates to SAP using the SAP .NET Connector to display pay stub data to the end user. The following diagram represents our solution architecture:

Solution Design

HTTP / HTTPSHTTP / HTTPS

SAP ServerSAP Server

IIS / MCMS ServerIIS / MCMS Server

ASPX TemplateASPX Template

Custom MCMSCustom MCMSPlaceholderPlaceholder

ControlControl

SAP .NETSAP .NETGeneratedGenerated

Proxy ClassProxy Class

MCMS Content MCMS Content RepositoryRepository

Site UserSite UserWeb BrowserWeb Browser

Visual StudioVisual Studio.NET 2003.NET 2003

Site AuthorSite AuthorWeb BrowserWeb Browser

Employee PayEmployee PayStub Data Stub Data

MCMSMCMSManaged APIManaged API

SAP SAP RFC / SOAPRFC / SOAP

SQL ServerSQL Server

11

44

33

22

Solution OverviewSolution Overview

11

22

33

44

Using the SAP .Net Connector, a custom placeholder control is developed providing access to the SAP data dictionary.

The MCMS Managed API allows data to be stored and retrieved for customizing the user interface during run-time.

Using the generated SAP .NET Connector proxy class, a web service is accessed and employee pay stub data returned.

Using the custom MCMS placeholder, site authors are able to customize the presentation and employees can view their pay stub information.

Page 7: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 7

SAP .NET Connector

SAP .NET Connector is a dedicated SAP product offering SAP NetWeaver – Microsoft .NET interoperability. The SAP .NET Connector provides both design time tools and run time libraries for communication between SAP systems and the Microsoft .NET platforms. The design time tools integrate with Microsoft Visual Studio .NET to provide developers the ability to generate .NET proxy classes based upon SAP system data dictionary objects. The run time libraries provide common functions used at run time by the proxy classes generated at design time to enable access to the SAP system.

The SAP .NET Connector supports both SAP Remote Function Calls (RFC) and Web services1 access to the SAP system. Using the SAP .NET Connector, developers can use any .NET language such as C#, Visual Basic .NET, Managed C++, or J# to create Web form, Windows form, console applications, or any other .NET project type.

SAP .NET Connector Architecture

The SAP .NET Connector allows the developer to connect to SAP systems either directly, using a WSDL file contained in the SAP IFR, or through a standard WSDL file.

For further information on the SAP .NET Connector visit http://www.sap.com/partners/marketplace/.

1 Web Services are only available in version 6.20 or higher of the SAP Web Application Server (WAS)

SAP .NET SAP .NET ConnectorConnector

Visual Studio .NET 2003Visual Studio .NET 2003

Microsoft .NETMicrosoft .NET

VBVB C#C# C++C++ J#J#

Web Web ServicesServicesApplicationApplication

.NET Connector Component .NET Connector Component (generated)(generated)

Common Language RuntimeCommon Language Runtime

mySAP TechnologymySAP Technology

BOR/DDICBOR/DDICInterface

repository

SOAP LayerSOAP Layer

Des

ign

Tim

eD

esig

n Ti

me

Run

R

un --

Tim

eTi

me

RFC LayerRFC Layer

Proxy Class Generator

.NET Connector Runtime

SAP .NET SAP .NET ConnectorConnector

Visual Studio .NET 2003Visual Studio .NET 2003

Microsoft .NETMicrosoft .NET

VBVB C#C# C++C++ J#J#

Web Web ServicesServicesApplicationApplication

.NET Connector Component .NET Connector Component (generated)(generated)

Common Language RuntimeCommon Language Runtime

mySAP TechnologymySAP Technology

BOR/DDICBOR/DDICInterface

repository

SOAP LayerSOAP Layer

Des

ign

Tim

eD

esig

n Ti

me

Run

R

un --

Tim

eTi

me

RFC LayerRFC Layer

Proxy Class Generator

.NET Connector Runtime

Page 8: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 8

Extending MCMS

Microsoft has made it very easy to extend the functionality of MCMS. The following four methods are the standard ways of extending MCMS functionality:

• Creating custom placeholder controls to provide a specialized user interface for authors contributing content to the Web site.

• Extending the Web Author application by customizing the appearance of the Web Author console or by adding or removing functionality in the Web Author console.

• Implementing extensions to the workflow process that is built into MCMS, such as notifying users by e-mail that their approval is required on a posting before it will be published to the Web site.

• Implementing MCMS to provide or consume Web services to extend the range of content sources for the Web site, or to provide the content on the Web site to other applications.

In our scenario, the author will need to customize the appearance of the external SAP content. They may also need to show the same type of information in different formats in other areas of the site. A custom placeholder control will meet these requirements the best.

Placeholders are editable regions in a template that authors can modify to add content to each page based on that template. Placeholders are implemented using placeholder controls in template files and placeholder definitions in templates. You can access the content stored in a placeholder programmatically through the Microsoft® Content Management Server (MCMS) Publishing API by accessing the Placeholder class.

A placeholder control is an ASP.NET-based server control that provides authors with a user interface for editing sections of a template and also renders presentation content for site users. You create custom placeholder controls to create specialized user interfaces for authors who use the Web Author.

Page 9: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 9

CREATING CUSTOM PLACEHOLDERS IN MCMS`

Creating custom placeholders in MCMS is very simple 3-step process:

1. Create a Custom Placeholder Control Project

2. Create a Custom Placeholder Control Class

3. Implement the Required Overridden Methods

Step 1: Creating the Custom Placeholder Control Project

To create a new placeholder control project in Visual Studio .NET:

1. In Visual Studio .NET, on the File menu, click New, and then click Project.

2. In the New Project window, in the Project Types section, select Visual C# Projects.

3. While the New Project window is still open, in the Templates section, select Web Control Library.

4. While the New Project window is still open, highlight the text next to Name, type McmsSapControls, and then click OK.

You have now created a project named McmsSapControls. The next step is to add the required MCMS references to the project.

*Note: You can also add a custom placeholder control to a pre-existing web control library project.

To add MCMS references to the project

1. On the Project menu, click Add Reference.

2. In the Add Reference window, click Browse.

3. In the Select Component window, browse to <InstallDrive>:\Program Files\Microsoft Content Management Server\Server\bin, and select the following components to add as references:

• Microsoft.ContentManagement.Common.dll

• Microsoft.ContentManagement.Publishing.dll

• Microsoft.ContentManagement.Publishing.Extensions.Placeholders.dll

• Microsoft.ContentManagement.Web.dll

• Microsoft.ContentManagement.WebControls.dll

4. Click Open, and then click OK.

Page 10: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 10

The MCMS components now appear in the Visual Studio Solution Explorer under References.

Step 2: Creating the Custom Placeholder Control Class

To create custom placeholder controls, you create a new class that is derived from the base placeholder control class BasePlaceholderControl.

To create the custom placeholder control class

1. In the Visual Studio Solution Explorer window, click McmsSapControls, and then on the File menu, click Add New Item.

2. In the Add New Item window, in the Categories section, select Local Project Items.

3. In the Templates section, select Class.

4. Select the text next to Name and type McmsSapControl.cs, and then click Open.

5. The class file opens, which includes a class signature and a constructor.

To inherit from the BasePlaceholderControl class

1. Add the following using directives to the top of the namespace so that you can use short names to refer to classes in these namespaces:

using System.Xml; using System.Xml.Xsl; using System.Web.UI.WebControls; using Microsoft.ContentManagement.Publishing; using Microsoft.ContentManagement.Publishing.Extensions.Placeholders; using Microsoft.ContentManagement.WebControls.Design; using Microsoft.ContentManagement.WebControls;

2. Add the following inheritance syntax to the McmsSapControl class so that the class inherits from the BasePlaceholder:

public class McmsSapControl : BasePlaceholderControl

The custom placeholder control now inherits from the BasePlaceholderControl class. It will not compile until the five required methods implemented as virtual methods in the BasePlaceholderControl class are implemented in the custom placeholder control.

3. Add method signatures for the required overridden methods of the BasePlaceholderControl class. The following code implements method signatures for the required methods:

Page 11: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 11

protected override void CreateAuthoringChildControls(BaseModeContainer authoringContainer) { } protected override void CreatePresentationChildControls(BaseModeContainer presentationContainer) { } protected override void LoadPlaceholderContentForAuthoring(PlaceholderControlEventArgs e) { } protected override void LoadPlaceholderContentForPresentation(PlaceholderControlEventArgs e) { } protected override void SavePlaceholderContent(PlaceholderControlSaveEventArgs e) { } protected override void OnPopulatingDefaultContent(PlaceholderControlCancelEventArgs e) { }

The custom placeholder control class you created is empty, but will now build without compile errors because the required method signatures are present. We will provide our implementation for these methods when we build out our solution in the “Integrating with SAP” section. For now, we’ll just discuss each of the methods briefly:

• CreateAuthoringChildControls - This method allows you to add your authoring controls to the AuthoringModeContainer collection parameter. Controls in this collection are displayed during authoring time.

• CreatePresentationChildControls – This method allows you to add your presentation controls to the PublishingModeContainer collection parameter. Controls in this collection are displayed at presentation time.

• LoadPlaceholderContentForAuthoring – This method allows you to load content from MCMS into the authoring controls.

• LoadPlaceholderContentForPresentation – This method allows you to load content from MCMS into the presentation controls.

• SavePlaceholderContent – This method allows you to save content modified with the authoring controls to the Placeholder object.

• OnPopulatingDefaultContent – This method allows you to display default content in the authoring control when creating the posting is first created.

Page 12: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 12

INTEGRATING WITH SAP

Now that we’ve created our custom placeholder, the following steps remain to integrate SAP and retrieve the pay stub information:

1. Install the Z_MSSP_GET_PAYROLL_RESULTS RFC into SAP

2. Create a Class Library Project for the SAP Connector Proxy Class

3. Connect to SAP and Generate the Connector Proxy Class

4. Build the User Interface for the Custom Placeholder

5. Implement the overridden methods in the custom placeholder

6. Create a MCMS template and posting to host our control

In order to retrieve the pay stub information we need from SAP, there are two SAP functions that we need to call:

• BAPI_GET_PAYROLL_RESULT_LIST – This function provides a list of payroll items given an employee identifier and a date range.

• Z_MSSP_GET_PAYROLL_RESULTS* – This function provides a detail view of a payroll item retrieved in the previous function call.

In addition to our pay stub information, we need some way of programmatically associating our employees’ Windows accounts with the corresponding employee identifiers in SAP. We need this association because it is likely our employees do not know their SAP employee identifier, nor should they be expected to provide it every time they access their payroll information. Since this information is stored in SAP, this can be easily done using the following remote function:

• BAPI_USR01DOHR_GETEMPLOYEE* – This function provides an employee’s SAP identifier given a username.

*Note: This is only one method for obtaining the employee identifier. Additional methods are discussed in the “Deployment Considerations” section of this document. For more information about remote functions available from SAP, consult your SAP documentation or visit the SAP Interface Repository at http://help.sap.com.

Step 1: Install the Z_MSSP_GET_PAYROLL_RESULTS RFC into SAP Install SAP Remote Function Call To setup the Transport Management System of IDES:

1. Log on as user DDIC in client 000. Enter transaction code STMS. If no dialog box appears prompting for transport domain and description, then the

Page 13: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 13

Transport Management System is already set up and you can omit the rest of this procedure. If a dialog box appears, continue to step 2.

2. In Transport domain, type the system ID of SAP IDES system. In Description, type Main transport domain.

3. Select Overview, and then click Systems. Select SAP System, point to Create, and then click Virtual system.

4. In System, type DUM. In Description, type Dummy system.

5. Select Extras, and then click Distribute and activate configuration.

6. Select Environment, and then click Transport Routes.

7. Select Configuration, point to Display, and then click Change.

8. Select Configuration, point to Standard configuration, and then click Development and production system.

9. In Source system, type the system ID of the SAP IDES system.

10. In Production system, type DUM.

11. Select Configuration, and then click Distribute and activate.

To install the PayStub extract function to an IDES system on the SAP Server

1. Copy Z_Mssp_Get_Payroll_Results.SPS to /usr/sap/trans/data, and then copy Z_Mssp_Get_Payroll_Results.SPS to /usr/sap/trans/cofiles.

2. Log on to the IDES client. Enter transaction code STMS.

3. Select Overview, and then click Imports.

4. To display the import queue, double-click the system ID of the SAP IDES system.

To add the new transport to the import queue

1. Select Extras, point to Other Requests, and then click Add.

2. Select Enter, and then click Yes in the dialog box. The import queue is displayed again with the additional request as the last entry.

3. Rest the pointer on the new request that you want to import, select Request, and then click Import.

4. Enter the current client (800 for IDES) and confirm the client in the confirmation dialog box. The system will import the entered transport request and display the Import Queue again when finished.

Step 2: Creating the SAP Class Library Project

To create the SAP class library project

1. In Visual Studio .NET, on the File menu click New, and then click Project.

2. In the New Project window, in the Project Types section, select Visual C# Projects.

3. While the New Project window is still open, in the Templates section, select Class Library.

Page 14: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 14

4. While the New Project is still open, highlight the text next to Name, type McmsSapIntegration, and then click OK.

You have now created a project named McmsSapIntegration. The next step is to generate the SAP .NET Connector proxy class.

Step 3: Generating the SAP .NET Connector Proxy Class

To generate the SAP .NET Connector Proxy class

1. In the Visual Studio Solution Explorer window, click McmsSapIntegration, and then on the File menu, click Add New Item.

2. In the Add New Item window, in the Categories section, select Local Project Items.

3. In the Templates section, select SAP Connector Class.

4. Select the text next to Name and type SapPaystubProxy.cs, and then click Open.

The following dialog opens:

Choose SAP Server (the default), and then click Next. The following dialog opens:

Page 15: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 15

Fill in the required logon information*, leave all other options at their default settings, and click Next.

*Note: You may need to get this information from your SAP system administrator.

The following dialog opens:

In the Name-Filter text box, enter the following function names, one at a time, and click the Search button. For each found method in the list box on the left, click the Add button. The function names we need to add are:

Page 16: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 16

BAPI_GET_PAYROLL_RESULT_LIST, Z_MSSP_GET_PAYROLL_RESULTS* and BAPI_USR01DOHR_GETEMPLOYEE.

*Note: This remote function will only be available in the wizard if it is transported into SAP. You may need to talk to your SAP system administrator to get access to this function.

When you are finished adding your functions, click the Next button.

Note: Notice how a brief description of the function appears under the left hand side list box. This information can be useful when determining which function to use for a given operation.

Your proxy class will be generated, and added to your project. You should see something like the following in your Visual Studio Solution Explorer window:

Page 17: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 17

If you select the proxy file (it’s the file with the extension .sapwsdl), and reveal hidden files using the Show All Files option in the Solution Explorer window, you will see the generated files:

Step 4: Building the User Interface for the Custom Placeholder

Defining our XML Schema

Now that we’ve generated the SAP .NET Connector Proxy class we need to build the user interface for the custom placeholder. The first step is to determine the functional needs of the site author and define an XML schema to store this information in the MCMS repository. Our site author needs the ability to determine which pay stub fields will be displayed within the detail view. Given this information, the following simple XML format will suffice:

<PayStubFields> <PayStubField name="Description" visible="1" /> <PayStubField name="CurrentHours" visible="1" /> <PayStubField name="CurrentAmount" visible="1" /> <PayStubField name="CurrentTotal" visible="1" /> <PayStubField name="YearlyHours" visible="1" /> <PayStubField name="YearlyAmount" visible="1" /> <PayStubField name="YearlyTotal" visible="1" /> </PayStubFields>

In this schema, the name of the SAP data field is represented by the name attribute, and the visibility determination is set using the visible attribute. Our user interface will allow the author to determine the column visibility and save this information to the MCMS repository. When an employee visits the site, this information will be used to render their individual pay stub information using only these visible columns.

Page 18: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 18

Authoring Mode User Interface Design

For the purposes of this article, we will make the authoring user interface as simple as possible. Because we are using XML for our MCMS content, we will simply use the XML editing control provided by MCMS for authoring. In an enterprise environment, you would probably want to replace this control with a more user-friendly control. The following figure illustrates this control:

Authoring View

Page 19: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 19

Presentation Mode User Interface Design

The presentation mode for the placeholder is composed of two tables. The first table is a summary table of all pay stubs for the employee. The employee will be able to click a link in the table and display the second table, which is represents a detailed view for an individual pay stub. The following figure illustrates how these two HTML tables will appear in our template:

Summary and Detail Presentation Views

To build these tables, we will use the ASP.NET DataGrid Web control. The DataGrid Web server control is a multi-column, data-bound grid. Extensive customization is available at design-time using the Property Builder dialog box. At design-time you can build columns that display and edit data, columns that contain Edit, Update, Cancel, and Select buttons, columns that contain custom buttons, and template columns.

Note: For more information regarding the ASP.NET DataGrid Web control, consult your Visual Studio .NET documentation.

Page 20: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 20

To make it easier to bind the SAP pay stub data to the grid controls, we will create a wrapper class that returns DataSet objects and add it to our integration library.

To create the simplified wrapper class

1. In the Visual Studio Solution Explorer window, click McmsSapIntegration, and then on the File menu, click Add New Item.

2. In the Add New Item window, in the Categories section, select Local Project Items.

3. In the Templates section, select Class.

4. Select the text next to Name and type PaystubData.cs, and then click Open.

5. Next, add the following code to your class:

using System; using System.Data; using SAP.Connector; namespace McmsSapIntegration { public class PaystubData { #region Private Fields SAPConnection sapConnection = null; BAPIRETURN1 returnMessages = null; BAPI7004_RLTable summaryData = null; ZMSSP_EEADDRESSTable addressData = null; ZMSSP_EEBANKDATATable bankData = null; ZMSSP_EEEARNINGSTable earningsData = null; ZMSSP_EEINFOTable infoData = null; ZMSSP_EELEAVEDATATable leaveData = null; ZMSSP_EEDEDUCTIONSTable postTaxDeductionData = null; ZMSSP_EEDEDUCTIONSTable preTaxDeductionData = null; ZMSSP_EEPAYHEADERTable headerData = null; ZMSSP_EETAXESTable taxData = null; ZMSSP_EEW4INFOTable w4Data = null; ZMSSP_EEALLSUBTOTALSTable subTotalData = null; #endregion #region Constants private const string ERROR = "E"; private const string PAY_DATE = "Paydate"; private const string SEQUENCE_NUMBER = "Sequencenumber"; private const string DESCRIPTION = "Description"; private const string CURRENT_HOURS = "CurrentHours"; private const string CURRENT_AMOUNT = "CurrentAmount"; private const string CURRENT_TOTAL = "CurrentTotal"; private const string YEARLY_HOURS = "YearlyHours"; private const string YEARLY_AMOUNT = "YearlyAmount"; private const string YEARLY_TOTAL = "YearlyTotal"; private const string HOURS = "Timehours"; private const string AMOUNT = "Amount"; private const string YTD_AMOUNT = "Ytd_Amount"; private const string SUB_TOTAL_AMOUNT = "Subtot_Amt";

Page 21: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 21

private const string SUB_YTD_AMOUNT = "Sub_Ytd_Amt"; private const string BANK_ACCT_NO = "Bank_Account_No"; private const string TRANSFER_AMOUNT = "Transfer_Amount"; private const string SPACE = "&nbsp"; #endregion #region Constructor public PaystubData() { Destination destination = new Destination(); // Note: you should load these values from your // application’s configuration file. destination.Client = [insert client number]; destination.Username = [insert username]; destination.Password = [insert password]; destination.Language = [insert language]; destination.AppServerHost = [insert server host]; destination.SystemNumber = [insert system number]; sapConnection = new SAPConnection(destination); } #endregion #region Public Methods public DataTable GetPaystubSummaryData(string employeeId) { this.returnMessages = new BAPIRETURN1(); this.summaryData = new BAPI7004_RLTable(); DataTable summaryTable = null; DataTable dt = new DataTable(); DataRow dr = null; SapPaystubProxy sapPaystub = new SapPaystubProxy(); sapPaystub.Connection = sapConnection; sapPaystub.Bapi_Get_Payroll_Result_List( employeeId, null, null, out returnMessages, ref summaryData); summaryTable = summaryData.ToADODataTable(); dt.Columns.Add(PAY_DATE); dt.Columns.Add(SEQUENCE_NUMBER); for(int i = 0; i < summaryTable.Rows.Count; i++) { dr = dt.NewRow(); dr[PAY_DATE] = summaryTable.Rows[i][PAY_DATE];

dr[SEQUENCE_NUMBER] = summaryTable.Rows[i][SEQUENCE_NUMBER];

dt.Rows.Add(dr); } return dt; } public DataTable GetPaystubDetailData(

Page 22: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 22

string employeeId, string sequenceNumber)

{ this.addressData = new ZMSSP_EEADDRESSTable(); this.bankData = new ZMSSP_EEBANKDATATable(); this.earningsData = new ZMSSP_EEEARNINGSTable(); this.infoData = new ZMSSP_EEINFOTable(); this.leaveData = new ZMSSP_EELEAVEDATATable(); this.postTaxDeductionData = new ZMSSP_EEDEDUCTIONSTable(); this.headerData = new ZMSSP_EEPAYHEADERTable(); this.preTaxDeductionData = new ZMSSP_EEDEDUCTIONSTable(); this.taxData = new ZMSSP_EETAXESTable(); this.subTotalData = new ZMSSP_EEALLSUBTOTALSTable(); this.w4Data = new ZMSSP_EEW4INFOTable(); SapPaystubProxy sapPaystub = new SapPaystubProxy(); sapPaystub.Connection = sapConnection; sapPaystub.Z_Mssp_Get_Payroll_Results( employeeId, sequenceNumber, out returnMessages, ref this.addressData, ref this.bankData, ref this.earningsData, ref this.infoData, ref this.leaveData, ref this.postTaxDeductionData, ref this.headerData, ref this.preTaxDeductionData, ref this.subTotalData, ref this.taxData, ref this.w4Data); DataTable earningsTable = this.earningsData.ToADODataTable(); DataTable postTaxDeductionsTable = this.postTaxDeductionData.ToADODataTable(); DataTable preTaxDeductionsTable = this.preTaxDeductionData.ToADODataTable(); DataTable subTotalTable = this.subTotalData.ToADODataTable(); DataTable taxTable = this.taxData.ToADODataTable(); DataTable bankTable = this.bankData.ToADODataTable(); DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add(DESCRIPTION); dt.Columns.Add(CURRENT_HOURS); dt.Columns.Add(CURRENT_AMOUNT); dt.Columns.Add(CURRENT_TOTAL); dt.Columns.Add(YEARLY_HOURS); dt.Columns.Add(YEARLY_AMOUNT); dt.Columns.Add(YEARLY_TOTAL); // Gross Salary Rows for (int i = 0; i < earningsTable.Rows.Count; i++) { dr = dt.NewRow(); dr[DESCRIPTION] = earningsTable.Rows[i][DESCRIPTION]; dr[CURRENT_HOURS] = earningsTable.Rows[i][HOURS]; dr[CURRENT_AMOUNT] = earningsTable.Rows[i][AMOUNT];

Page 23: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 23

dr[YEARLY_AMOUNT] = earningsTable.Rows[i][YTD_AMOUNT]; dt.Rows.Add(dr); } if(subTotalTable.Rows.Count > 0) { dr = dt.NewRow(); dr[DESCRIPTION] =

subTotalTable.Rows[0][DESCRIPTION]; dr[CURRENT_AMOUNT] = subTotalTable.Rows[0][SUB_TOTAL_AMOUNT]; dr[CURRENT_TOTAL] = subTotalTable.Rows[0][SUB_TOTAL_AMOUNT]; dr[YEARLY_AMOUNT] =

subTotalTable.Rows[0][SUB_YTD_AMOUNT]; dr[YEARLY_TOTAL] = subTotalTable.Rows[0][SUB_YTD_AMOUNT]; dt.Rows.Add(dr); AddSpace(dt); } // Tax Withheld Rows for (int i = 0; i < taxTable.Rows.Count; i++) { dr = dt.NewRow(); dr[DESCRIPTION] = taxTable.Rows[i][DESCRIPTION]; dr[CURRENT_AMOUNT] = taxTable.Rows[i][AMOUNT]; dr[YEARLY_AMOUNT] = taxTable.Rows[i][YTD_AMOUNT]; dt.Rows.Add(dr); } if(subTotalTable.Rows.Count > 0) { dr = dt.NewRow(); dr[DESCRIPTION] =

subTotalTable.Rows[1][DESCRIPTION]; dr[CURRENT_AMOUNT] =

subTotalTable.Rows[0][SUB_TOTAL_AMOUNT]; dr[CURRENT_TOTAL] =

subTotalTable.Rows[1][SUB_TOTAL_AMOUNT]; dr[YEARLY_AMOUNT] =

subTotalTable.Rows[0][SUB_YTD_AMOUNT]; dr[YEARLY_TOTAL] =

subTotalTable.Rows[1][SUB_YTD_AMOUNT]; dt.Rows.Add(dr); AddSpace(dt); } // Net Salary Rows if(subTotalTable.Rows.Count > 4) { dr = dt.NewRow(); dr[DESCRIPTION] =

subTotalTable.Rows[5][DESCRIPTION]; dr[CURRENT_TOTAL] =

subTotalTable.Rows[5][SUB_TOTAL_AMOUNT]; dr[YEARLY_TOTAL] =

subTotalTable.Rows[5][SUB_YTD_AMOUNT]; dt.Rows.Add(dr);

Page 24: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 24

AddSpace(dt); } // Bank Rows if(bankTable.Rows.Count > 0) { dr = dt.NewRow(); dr[DESCRIPTION] =

"Checking Account: " + bankTable.Rows[0][BANK_ACCT_NO];

dr[CURRENT_AMOUNT] = bankTable.Rows[0][TRANSFER_AMOUNT];

dt.Rows.Add(dr); dr = dt.NewRow(); dr[DESCRIPTION] =

"DIRECT DEPOSIT AMOUNT"; dr[CURRENT_AMOUNT] =

bankTable.Rows[0][TRANSFER_AMOUNT]; dr[CURRENT_TOTAL] =

bankTable.Rows[0][TRANSFER_AMOUNT]; dt.Rows.Add(dr); AddSpace(dt); } // Check Total Rows if(bankTable.Rows.Count > 0 &&

subTotalTable.Rows.Count > 0) { dr = dt.NewRow(); dr[DESCRIPTION] = "CHECK AMOUNT"; decimal transferAmount =

Convert.ToDecimal( bankTable.Rows[0][TRANSFER_AMOUNT]);

decimal netPay = Convert.ToDecimal( subTotalTable.Rows[5][SUB_TOTAL_AMOUNT]);

decimal checkAmount = netPay - transferAmount; dr[CURRENT_TOTAL] =

String.Format(checkAmount.ToString(), "c"); dt.Rows.Add(dr); AddSpace(dt); } return dt; }

public string GetEmployeeIdFromUsername(string userName) { string employeeId = String.Empty; BAPIRET2 ret = new BAPIRET2(); SapPaystubProxy sapPaystub = new SapPaystubProxy(); sapPaystub.Connection = sapConnection; sapPaystub.Bapi_Usr01dohr_Getemployee( null, null, userName, out employeeId, out ret); if(ret.Type != ERROR)

Page 25: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 25

{ return employeeId; } else { return String.Empty; } } #endregion #region Private Methods private static void AddSpace(DataTable table) { DataRow dr = table.NewRow(); dr[DESCRIPTION] = SPACE; table.Rows.Add(dr); } #endregion }

This class implements two public methods for retrieving pay stub data and one for returning the employee identifier for a given user:

• GetPaystubSummaryData – This method takes an employee identifier parameter and returns a DataTable representing the summary of pay stub information for the employee.

• GetPaystubDetailData – This method takes an employee identifier and a pay stub sequence number and returns a DataTable representing the detail for a single paystub.

• GetEmployeeIdFromUserName – This method takes a user name and returns a SAP employee identifier.

Step 5: Implementing the Overridden Methods in the Custom Placeholder

The next step is to add code to our placeholder class that implements the overridden methods from the BasePlaceHolder class. First, you will need to set a reference to the McmsSapIntegration project from your placeholder project.

To set the reference to the McmsSapIntegration project

1. In the Visual Studio Solution Explorer window, right click on the References node in your placeholder control project.

2. Click Add Reference….

3. In the Add Reference dialog, click the Projects tab, click on the McmsSapIntegration project in the list of projects, click Select and click OK.

Next, modify your placeholder class file so it contains the following code:

using System;

Page 26: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 26

using System.Data; using System.Xml; using System.Xml.Xsl; using System.Web.UI.WebControls; using Microsoft.ContentManagement.Publishing; using Microsoft.ContentManagement.Publishing.Extensions.Placeholders; using Microsoft.ContentManagement.WebControls.Design; using Microsoft.ContentManagement.WebControls; using McmsSapIntegration; namespace McmsWebControlLibrary.PlaceholderControls { public class McmsSapControl : BasePlaceholderControl { #region Private Members private TextBox xmlEditControl; private Xml xmlPresentationControl; private System.Web.UI.WebControls.DataGrid summaryDataGrid; private System.Web.UI.WebControls.DataGrid detailDataGrid; private string userName = String.Empty; private string employeeId = String.Empty; #endregion public McmsSapControl() {

PaystubData paystubData = new PaystubData(); this.userName = this.Page.User.Identity.Name; this.employeeId =

paystubData.GetEmployeeIdFromUsername(userName); } protected override void CreateAuthoringChildControls(BaseModeContainer authoringContainer) { this.xmlEditControl = new TextBox(); this.xmlEditControl.ID = "XmlAuthoringControl"; this.xmlEditControl.TextMode =

System.Web.UI.WebControls.TextBoxMode.MultiLine; this.xmlEditControl.Height = 300; this.xmlEditControl.Width = 450; authoringContainer.Controls.Add(this.xmlEditControl); } protected override void

CreatePresentationChildControls( BaseModeContainer presentationContainer)

{ this.xmlPresentationControl = new Xml(); this.xmlPresentationControl.ID = "XmlPresentationControl"; presentationContainer.Controls.Add(

this.xmlPresentationControl); // Setup the Summary Grid this.summaryDataGrid = new DataGrid(); this.summaryDataGrid.ID = "summaryDataGrid"; this.summaryDataGrid.AllowPaging = true; this.summaryDataGrid.CellPadding = 3; this.summaryDataGrid.AutoGenerateColumns = false; this.summaryDataGrid.Width = new Unit("50%"); this.summaryDataGrid.BorderWidth = new Unit("1px"); this.summaryDataGrid.PagerStyle.NextPageText = "Next >"; this.summaryDataGrid.PagerStyle.PrevPageText =

"< Previous";

Page 27: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 27

this.summaryDataGrid.PagerStyle.HorizontalAlign = HorizontalAlign.Left;

this.summaryDataGrid.PagerStyle.Mode = PagerMode.NextPrev; this.summaryDataGrid.PageIndexChanged += new

System.Web.UI.WebControls.DataGridPageChangedEventHandler( this.summaryDataGrid_PageIndexChanged);

presentationContainer.Controls.Add(this.summaryDataGrid); // Setup the Detail Grid this.detailDataGrid = new DataGrid(); this.detailDataGrid.ID = "detailDataGrid"; this.detailDataGrid.AllowPaging = false; this.detailDataGrid.CellPadding = 3; this.detailDataGrid.AutoGenerateColumns = false; this.detailDataGrid.Width = new Unit("70%"); this.detailDataGrid.BorderWidth = new Unit("1px"); presentationContainer.Controls.Add(this.detailDataGrid); } protected override void

LoadPlaceholderContentForAuthoring(PlaceholderControlEventArgs e) { EnsureChildControls(); try { this.xmlEditControl.Text =

((XmlPlaceholder)this.BoundPlaceholder).XmlAsString; } catch (Exception exp) { // show the error as placeholder content this.xmlPresentationControl.DocumentContent =

"<error>" + exp.Message + "</error>"; } } protected override void

LoadPlaceholderContentForPresentation( PlaceholderControlEventArgs e)

{ EnsureChildControls(); BoundColumn boundColumn = null; HyperLinkColumn hyperLinkColumn = null; PaystubData paystubData = new PaystubData(); // Sequence Number boundColumn = new BoundColumn(); boundColumn.DataField = "Sequencenumber"; boundColumn.HeaderText = "Sequence #"; boundColumn.HeaderStyle.HorizontalAlign =

HorizontalAlign.Center; boundColumn.HeaderStyle.Width = new Unit("35%"); boundColumn.ItemStyle.HorizontalAlign =

HorizontalAlign.Center; this.summaryDataGrid.Columns.Add(boundColumn); // Paydate boundColumn = new BoundColumn(); boundColumn.DataField = "Paydate"; boundColumn.HeaderText = "Pay Date"; boundColumn.HeaderStyle.HorizontalAlign =

HorizontalAlign.Center;

Page 28: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 28

boundColumn.HeaderStyle.Width = new Unit("40%"); boundColumn.ItemStyle.HorizontalAlign =

HorizontalAlign.Center; this.summaryDataGrid.Columns.Add(boundColumn); // Details link hyperLinkColumn = new HyperLinkColumn(); hyperLinkColumn.Text = "Details..."; hyperLinkColumn.HeaderStyle.Width = new Unit("25%"); hyperLinkColumn.ItemStyle.HorizontalAlign =

HorizontalAlign.Center; string navigateUrl =

AppendQueryString( CmsHttpContext.Current.Posting.Url, "sequence", "{0}");

hyperLinkColumn.DataNavigateUrlField = "Sequencenumber"; hyperLinkColumn.DataNavigateUrlFormatString = navigateUrl; this.summaryDataGrid.Columns.Add(hyperLinkColumn); // Bind the summary data DataTable summaryTable =

paystubData.GetPaystubSummaryData(this.employeeId);

this.summaryDataGrid.DataSource = summaryTable; this.summaryDataGrid.DataBind(); // Load the xml settings and determine which columns are

// visible in the data grid string sequenceNumber =

this.Page.Request.QueryString["sequence"]; if (sequenceNumber != null) { string xmlContent =

((XmlPlaceholder)this.BoundPlaceholder).XmlAsString; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xmlContent); XmlNode node =

xmlDocument.SelectSingleNode( "descendant::PayStubField[@name='Description']");

if (node.Attributes["visible"].Value == "1") { // Description boundColumn = new BoundColumn(); boundColumn.DataField = "Description"; boundColumn.HeaderText = "Description"; boundColumn.HeaderStyle.HorizontalAlign =

HorizontalAlign.Center; this.detailDataGrid.Columns.Add(boundColumn); } node = xmlDocument.SelectSingleNode( "descendant::PayStubField[@name='CurrentHours']"); if (node.Attributes["visible"].Value == "1") { // CurrentHours boundColumn = new BoundColumn(); boundColumn.DataField = "CurrentHours"; boundColumn.HeaderText = "Hours";

Page 29: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 29

boundColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;

boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Right;

this.detailDataGrid.Columns.Add(boundColumn); } node = xmlDocument.SelectSingleNode(

"descendant::PayStubField[@name='CurrentAmount']");

if (node.Attributes["visible"].Value == "1") { // CurrentAmount boundColumn = new BoundColumn(); boundColumn.DataField = "CurrentAmount"; boundColumn.HeaderText = "Amount"; boundColumn.HeaderStyle.HorizontalAlign =

HorizontalAlign.Center; boundColumn.ItemStyle.HorizontalAlign =

HorizontalAlign.Right; this.detailDataGrid.Columns.Add(boundColumn); } node = xmlDocument.SelectSingleNode(

"descendant::PayStubField[@name='CurrentTotal']");

if (node.Attributes["visible"].Value == "1") { // CurrentTotal boundColumn = new BoundColumn(); boundColumn.DataField = "CurrentTotal"; boundColumn.HeaderText = "Total"; boundColumn.HeaderStyle.HorizontalAlign =

HorizontalAlign.Center; boundColumn.ItemStyle.HorizontalAlign =

HorizontalAlign.Right; this.detailDataGrid.Columns.Add(boundColumn); } node = xmlDocument.SelectSingleNode(

"descendant::PayStubField[@name='YearlyHours']");

if (node.Attributes["visible"].Value == "1") { // YearlyHours boundColumn = new BoundColumn(); boundColumn.DataField = "YearlyHours"; boundColumn.HeaderText = "YTD Hours"; boundColumn.HeaderStyle.HorizontalAlign =

HorizontalAlign.Center; boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Right; this.detailDataGrid.Columns.Add(boundColumn); } node = xmlDocument.SelectSingleNode(

"descendant::PayStubField[@name='YearlyAmount']");

if (node.Attributes["visible"].Value == "1") { // YearlyAmount boundColumn = new BoundColumn(); boundColumn.DataField = "YearlyAmount";

Page 30: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 30

boundColumn.HeaderText = "YTD Amount"; boundColumn.HeaderStyle.HorizontalAlign =

HorizontalAlign.Center; boundColumn.ItemStyle.HorizontalAlign =

HorizontalAlign.Right; this.detailDataGrid.Columns.Add(boundColumn); } node = xmlDocument.SelectSingleNode(

"descendant::PayStubField[@name='YearlyTotal']");

if (node.Attributes["visible"].Value == "1") { // YearlyTotal boundColumn = new BoundColumn(); boundColumn.DataField = "YearlyTotal"; boundColumn.HeaderText = "YTD Total"; boundColumn.HeaderStyle.HorizontalAlign =

HorizontalAlign.Center; boundColumn.ItemStyle.HorizontalAlign =

HorizontalAlign.Right; this.detailDataGrid.Columns.Add(boundColumn); } DataTable detailTable =

paystubData.GetPaystubDetailData( this.employeeId, sequenceNumber);

detailDataGrid.DataSource = detailTable; detailDataGrid.DataBind(); detailDataGrid.Visible = true; } else { detailDataGrid.Visible = false; } } protected override void

SavePlaceholderContent(PlaceholderControlSaveEventArgs e) { EnsureChildControls(); try { ((XmlPlaceholder)this.BoundPlaceholder).XmlAsString =

this.xmlEditControl.Text; } catch (Exception exp) { // Possible validation exceptions // If you want, you can override it with your own

// custom exception string newExceptionMessage =

String.Format( "[{0} \"{1}\"] Error: {2}", this.GetType().Name, this.ID, exp.Message );

Exception overriddenException = new Exception(newExceptionMessage, exp);

// Raise new exception so the BasePlaceholderControl

Page 31: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 31

// can handle it throw overriddenException; } } protected override void

OnPopulatingDefaultContent(PlaceholderControlCancelEventArgs e) { try { string xmlContent =

@”<PayStubFields> <PayStubField name="Description" visible="1" /> <PayStubField name="CurrentHours" visible="1" /> <PayStubField name="CurrentAmount" visible="1" /> <PayStubField name="CurrentTotal" visible="1" /> <PayStubField name="YearlyHours" visible="1" /> <PayStubField name="YearlyAmount" visible="1" /> <PayStubField name="YearlyTotal" visible="1" /> </PayStubFields>”;

xmlEditControl.Text = xmlContent; } catch (Exception f) { string message = f.Message; } } private string AppendQueryString(

string url, string parameter, string value) { int startPos = url.IndexOf("&" + parameter + "="); string newParam = String.Empty; if (url.IndexOf("?") != -1) { newParam = "&" + parameter + "=" + value; } else { newParam = "?" + parameter + "=" + value; return url + newParam; } if (startPos != -1) { string oldParam = ""; int endPos = url.IndexOf("&", startPos + 1); if (endPos != -1) { oldParam =

url.Substring( startPos, endPos - startPos);

} else { oldParam =

url.Substring( startPos, url.Length - startPos);

} url = url.Replace(oldParam, newParam); } else

Page 32: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 32

{ url = url + newParam; } return url; } private void summaryDataGrid_PageIndexChanged(

object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)

{ PaystubData paystubData = new PaystubData(); DataTable summaryTable =

paystubData.GetPaystubSummaryData(this.employeeId"); summaryDataGrid.DataSource = summaryTable; summaryDataGrid.CurrentPageIndex = e.NewPageIndex; summaryDataGrid.DataBind(); }

} }

Step 6: Creating the MCMS Template and Posting to Host the Placeholder

Next, we need to create a MCMS Template to host the new placeholder control.

To create the MCMS Template

1. In the Visual Studio Solution Explorer window, click on your MCMS web project, and then on the File menu, click Add New Item.

2. In the Add New Item window, in the Categories section, select Content Management Server.

3. In the Templates section, select MCMS Template File.

4. Select the text next to Name and type SapIntegration.aspx, and then click Open.

5. Add the MCMS authoring console control by dragging and dropping it from the Visual Studio Solution Explorer window (Note: for our purposes, we are using the default console provided with the WoodGrove sample site in MCMS).

6. In the Toolbox window, right click on an open tab and select Add/Remove Items….

7. In the Customize Toolbox window, click the Browse button on the .NET Framework Components tab and locate the McmsSapControl.dll file we created in the previous section, click Open and click OK to close the dialog. The MCMS custom placeholder control now appears on the toolbox.

8. In the MCMS Template Explorer window, right click on Templates and click New Template. Name your template SAP Integration.

9. Right click on the newly created template and click Properties.

Page 33: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 33

10. In the Properties window, click on the PlaceholderDefinitions property. The Placeholder Definition Collection Editor window loads.

11. Click the down arrow button next to the Add button and click XmlPlaceholderDefinition. Name your definition SapPaystubPlaceholderDefinition and Click OK.

12. Modify the TemplateFile property and select the file you created in the Select File dialog.

13. Drag and drop an instance of the McmsSapControl onto the newly created template file.

14. With the placeholder control selected on the template, update the PlaceholderToBind property in the Properties window to reference the newly created definition.

15. In the MCMS Template Explorer window, right click the template and click Save. Right click again and click Check In.

16. Compile the project and navigate to your web site in Internet Explorer.

To create a MCMS posting

1. Once you have logged into your site, switch to edit mode and click Create New Page.

2. Browse through the Template Gallery and select the template you created in the previous section. The template opens in authoring mode.

3. Click Save and Exit, save the posting as PayStubs.htm, and then click Submit. Your new posting should look like the following:

Page 34: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 34

DEPLOYMENT CONSIDERATIONS

In the solution we have presented here, we associated the Windows user name with a SAP employee identifier using the method BAPI_USR01DOHR_GETEMPLOYEE for subsequent calls to the SAP server. Because your SAP implementation may vary from ours, you may need to get this association from another source. Other options include:

Active Directory – Active directory is fully extensible and provides the ability add custom attributes for Windows users. For more information visit the Microsoft Active Directory web site: http://www.microsoft.com/windowsserver2003/technologies/directory/activedirectory/default.mspx

User Profile Application Block – This custom component provided by Microsoft can be used if you want to create a custom profiling solution. For more information, visit the Microsoft .NET Architecture center: http://msdn.microsoft.com/architecture/

Microsoft SharePoint Portal Server – SharePoint provides a robust profiling mechanism. For more information visit the Microsoft SharePoint Portal Server web site: http://www.microsoft.com/sharepoint/

Also, it is always good practice to store configuration information in a secure location, and load this information at runtime. For simplicity, we coded this information into the constructor of our pay stub class. This is not a recommended practice. For more information on loading information from a configuration file, consult your Visual Studio .NET documentation.

Page 35: MCMS Integration with SAP avanadedownload.microsoft.com/.../CMSIntegrationWithSAP.pdf · 2018. 10. 13. · Microsoft Content Management Server Integration with SAP Using MCMS Custom

MCMS Integration with SAP / Using MCMS Custom Placeholders and the SAP .NET Connector 35

CONCLUSION

Integrating the SAP .NET Connector and MCMS 2002 allows development of custom placeholders with which content authors can effortlessly configure MCMS templates to display key business data to be shared with customers, business partners, and employees.

In our example we developed a custom placeholder by:

Creating a Custom Placeholder Control Project

Creating a Custom Placeholder Control Class

Implementing the required overridden methods

We then integrated our custom placeholder with SAP by:

Creating a Class Library Project for the SAP Connector Proxy Class

Connecting to SAP and generating the Connector Proxy Class

Building the user interface for the custom placeholder

Implementing the overridden methods in the custom placeholder

Creating a MCMS template and posting to host our control

When the steps outlined in this paper are completed, you can view SAP payroll data by browsing to http://<servername>/WoodgroveNet/PayStubs.htm on the MCMS Web site.

Related Links

For more information about MCMS 2002, see http://www.microsoft.com/cmserver or MCMS 2002 Help. MCMS 2002 Help is available from the following sources:

The product setup screen

The documentation folder on the CD

The Site Manager menu selection bar Help option

For more information about SAP and the SAP .NET Connector, see:

http://www.sap.com

http://ifr.sap.com

http://service.sap.com/connectors (available to SAP customers and partners)