17
 SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx .sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 1 SAP Portal    Communicate a System Message to All Portal Users, Part 1 Applies to: SAP Portal, every version that has a KM installed. Developed on Portal 7.00 and also tested on 7.02. Summary This paper will detail an application that allows the administrator to publish a message to all users; a feature similar to ECC but that the SAP Portal is missing. The application is a portal application (PAR) that AJAX to load a message from the KM. Leveraging the KM features the message can be programmed to be displayed only at certain times. Author: Tobias Hofmann Company: CPM Braxis Capgemini Created on: 6. October 2011 Author Bio Tobias is an SAP Mentor, an SCN topic leader for portals (2010 & 2011), speaker at SAP events (TechEd, SIT) and highly active in the Brazilian SCN community. My main focus area is the SAP Portal, integration, landscape design and performance. Other areas of interest are other portal software, open source, the possibility AJAX offers and mobile access to SAP.

SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

  • Upload
    alkimer

  • View
    10

  • Download
    0

Embed Size (px)

DESCRIPTION

SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

Citation preview

Page 1: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 1/17

 

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 1

SAP Portal  –  Communicate aSystem Message to All PortalUsers, Part 1

Applies to:

SAP Portal, every version that has a KM installed. Developed on Portal 7.00 and also tested on 7.02.

Summary

This paper will detail an application that allows the administrator to publish a message to all users; a featuresimilar to ECC but that the SAP Portal is missing. The application is a portal application (PAR) that AJAX toload a message from the KM. Leveraging the KM features the message can be programmed to be displayedonly at certain times.

Author:  Tobias Hofmann

Company:  CPM Braxis Capgemini

Created on: 6. October 2011

Author Bio

Tobias is an SAP Mentor, an SCN topic leader for portals (2010 & 2011), speaker at SAPevents (TechEd, SIT) and highly active in the Brazilian SCN community. My main focus area isthe SAP Portal, integration, landscape design and performance. Other areas of interest areother portal software, open source, the possibility AJAX offers and mobile access to SAP.

Page 2: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 2/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 2

Table of Contents

Problem description ............................................................................................................................................ 3 

Portal Application ................................................................................................................................................ 4 

Create the portal application in the NWDS ..................................................................................................... 4  

Create the Abstract Portal Component ........................................................................................................... 5 

Create the JSP file for loading the message................................................................................................... 7 

Compile and deploy ........................................................................................................................................ 9 

KM configuration ............................................................................................................................................... 12 

PCD configuration ............................................................................................................................................. 12 

Create iView .................................................................................................................................................. 12 

Configure the framework page ...................................................................................................................... 14 

Result ............................................................................................................................................................. 15 

Related Content ................................................................................................................................................ 16 

Disclaimer and Liability Notice .......................................................................................................................... 17 

Page 3: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 3/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 3

Problem description

The SAP ECC ABAP system offers a functionality to broadcast system messages to all users. The SAPPortal isn’t offering this functionality. When it comes to communicate urgent messages to the end user likemaintenance hours or new changes you can only use the content publishing process through iViews, WPC,KM and so on. This process is quite complex and lacks an easy to use alternative to just push a message tothe browser.

To give a solution, this paper will guide you through the process of

  Creating the portal application (PAR)

  Integrating the PAR into the portal content

  Usage of the KM for storing and controlling the system messages.

 After implementing the solution described in this article, the portal will be able to show a message below themasthead.

Page 4: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 4/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 4

Portal Application

The portal application will be responsible for checking and showing any new message created by the contentadministrator. The PAR consists of the portal component and a JSP file. The JSP file contains the AJAXcode to load the message from the KM and to show it in the browser.

Create the portal application in the NWDS

1. Start the NWDS2. Create a new Portal Application Project

3. Project name: PortalSystemMessage

Page 5: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 5/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 5

4. Click Finish

Create the Abstract Portal Component

1. Open the portalapp.xml file

2. Select “More …” in the Components section

3. Create a new Portal Component

Page 6: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 6/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 6

4. Create the Portal ComponentName: SystemMessageClassName: SystemMessage

Package Name: Choose a good package name. Example: com.tobias.test  

5. Select Finish6. This will create the following stub source code:

package com.tobias.test.portalsystemessage;

import com.sapportals.portal.prt.component.*;

public class SystemMessage extends AbstractPortalComponent

{

public void doContent(IPortalComponentRequest request,

IPortalComponentResponse response) {}

}

7. Modify the source code to include a JSP file:

package com.tobias.test.portalsystemessage;

import com.sapportals.portal.prt.component.*;

Page 7: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 7/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 7

public class SystemMessage extends AbstractPortalComponent

{

public void doContent(IPortalComponentRequest request, IPortalComponentResponse

response)

{

com.sapportals.portal.prt.resource.IResource jspResource =

request.getResource("jsp", "jsp/message.jsp");

response.include(request, jspResource);

}

}

Note: The code linecom.sapportals.portal.prt.resource.IResource jspResource = request.getResource("jsp", "jsp/message.jsp"); creates a reference to the file messge.jsp stored in the folder jsp of the same PAR. The following line:response.include(request, jspResource);will include the jsp file in the output of the servlet response. This will actually make the browser load the jsp file andinclude it in the portal HTML code. This also means that we have to provide the message.jsp file.

Create the JSP file for loading the message

1.  Navigate to the jsp folder of the PAR. 

2. Right click the jsp folder and select New -> Other3. Select Simple -> File

4. File Name: message.jsp

Page 8: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 8/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 8

5. Select Finish6. Change to the Source view of the message.jsp file and paste the following code:

<%@ page import = "com.sapportals.htmlb.*" %>

<%@ page import = "com.sapportals.portal.prt.runtime.PortalRuntime.*" %>

<div id="systemMessage"></div>

<script type="text/javascript">

function createXmlHttpRequest() {

if (window.XMLHttpRequest) {

return new window.XMLHttpRequest;

}

else {

try {

return new ActiveXObject("MSXML2.XMLHTTP.3.0");

}

catch(ex) {

}

}

}

function insertMessage(xml, divId) {if ( (xml.readyState == 4) && (xml.status == 200) ) {

document.getElementById(divId).innerHTML = xml.responseText;

}

}

function loadMessage() {

var divId = "systemMessage";

var url = "/irj/go/km/docs/documents/Messages/SystemMessage.txt";

Page 9: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 9/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 9

xml = createXmlHttpRequest();

xml.open('GET', url, true);

xml.onreadystatechange = function() { insertMessage(xml, divId); }

xml.send("");

}

var int = self.setInterval("loadMessage()",5000);

</script>

Note: The part where the AJAX object gets created is taken from the Microsoft [1] and makes sure that it worksfor Internet Explorer 7. The <script> section has to be after the HTML div. If not, Internet Explorer won’tfind the div and give an object not found error.

To know what the HTML and Javascript code above does, here is a small explanation:

  <div id="systemMessage"></div>

Defines an HTML DIV element where the actual message will be loeaded by AJAX.

  function createXmlHttpRequest() {

Create the actual object that will carry out the AJAX calls to the Portal KM.

  function insertMessage(xml, divId)

Inserts the HTML / text block that got loaded from the backend into the DIV

  function loadMessage() {

Responsible for actually loading the message from the KM. The DIV to load the message to isdefined by:

  var divId = "systemMessage";

while the location of the file on the KM is defined by:

  var url = "/irj/go/km/docs/documents/Messages/SystemMessage.txt";

  xml.onreadystatechange = function() { insertMessage(xml, divId); }

 After carrying out the AJAX calls, this line will call the function InsertMessage and pass the response(xml) and the DIV to load the response to.

1. var int = self.setInterval("loadMessage()",5000);

This is the Javascript that starts everything. After the browser loaded the HTML with the Javascript,the Javascript triggers a call to the function loadMessage every 5 seconds.

Compile and deploy

The portalapp.xml file should like like:

<?xml version="1.0" encoding="UTF-8"?>

<application>

<application-config>

<property name="SharingReference"

value="com.sap.portal.pagebuilder,com.sap.portal.common.commonservices,SAPJ2EE::libra

ry:com.sap.portal.common,com.sap.portal.htmlb"/>

<property name="SecurityArea" value="NetWeaver.Portal"/>

<property name="Vendor" value="com.sap"/>

</application-config>

<components>

<component name="SystemMessage">

<component-config>

<property name="ClassName"

value="com.tobias.test.portalsystemessage.SystemMessage"/>

Page 10: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 10/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 10

</component-config>

<component-profile/>

</component>

</components>

<services/>

</application>

Note: You should change the part <property name="Vendor" value="com.sap"/> to reflect your own

name or company. This part is of interest when the end user accesses the URL of the portal applicationdirectly (Security Zone).

1. Compile the file (PAR)

PAR file: <path to file>\<your package name>.PortalSystemMessage.par2. Deploy it to the portal server

a. Access the URL /irj/irjb. Upload the file and deploy it.

Page 11: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 11/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 11

3. Test the file by accessing it directlya. Log on on to the portalb. Enter the URL: http://server:port/irj/servlet/prt/portal/prtroot/<your package

name>.PortalSystemMessage.SystemMessagec. The page loaded will look like the image below as currently there is no message to load from

the KM.

Page 12: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 12/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 12

KM configuration

The PAR file uses AJAX to load the message to display from the KM. To make this work the KM needs tostore the file at a specific location. The KM location and the file name of the message is specified by theJavascript variable url in the JSP file:

var url = "/irj/go/km/docs/documents/Messages/SystemMessage.txt";

1. Create the folder Messages 2. Create the file SystemMessage.txt  

3. Insert the text:<p style="color:red; font-size:30px;" width="100%" height="50px" align="center">System Message from Administrator: LOREM IPSUM</p>

When you call now the application directly by the above URL, the result will be:

PCD configuration

To show the system message to all users the portal application has to be accessible for all users. A goodlocation is the default framework page. This implies that an iView for the portal component has to be createdand incorporated into the framework page of the users.

Create iView

1. Navigate to a folder where you want to store the iView and select New -> iView2. Select Portal component

3. Select the right portal component

4. Select the portal component

5. Enter the iView properties

Page 13: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 13/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 13

6. After finishing the iView creation, open the iView to edit the properties

7. The iView needs to be added to the framework page in a way that makes it invisible at first. Thereshouldn’t be a default height or tray.

Page 14: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 14/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 14

Configure the framework page

1. Add the iView to the default framework page

2. Place the iView below the Masthead iView in the Page Layout

Page 15: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 15/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 15

Result

 A user that is assigned to the modified framework page can now log on to the portal without noticing adifference.

 As soon as a System Message is placed in the predefined KM path the AJAX call will load the message fromthe KM and load it into the DIV element.

It is not necessary for the above code to work to be included as a separate PAR / iView. The Javascript codecan also added to an already existing iView application, like the Masthead.

Page 16: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 16/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 16

Related Content

Microsoft: XMLHttpRequest Object 

SAP Portal – Communicate a System Message to All Portal Users, Part 2 

Page 17: SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

7/18/2019 SAP Portal – Communicate a System Message to All Portal Users%2c Part 1.Docx

http://slidepdf.com/reader/full/sap-portal-communicate-a-system-message-to-all-portal-users2c-part-1docx 17/17

  SAP Portal  – Communicate a System Message to All Portal Users, Part 1

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is notsupported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article orcode sample, including any liability resulting from incompatibility between the content within this document and the materials andservices offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of thisdocument.