Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management...

20
Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 1 Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API Applies to: SAP NetWeaver Developer Studio (NWDS) version 2.0.7 or 2.0.9 or 7.0.11 and SAP Web Application Server (WAS) version 6.40 or 7.0. Summary Knowledge Management capabilities in SAP NetWeaver™ provides a central, role-specific point of entry to unstructured information from various data sources in the portal. This unstructured information can exist in different formats such as text documents, presentations, or HTML files. Workers in an organization can access information from different source such as file servers, their intranet, or the World Wide Web. A generic framework integrates these data sources and provides access to the information contained in them through the portal. Knowledge Management functions support you in structuring information and making it available to the correct target audience. These functions include search, classification, and subscriptions. You can use these functions on all content of integrated data sources, as long as the technical conditions are met. The repository framework of KM is the physical storage location for documents. It provides a range of basic functions for documents and folders. It enables the integration of documents into a virtual hierarchy and a namespace. The documents can be stored on different systems (Windows, WebDAV, or HTTP). Repository managers are used to access these systems. There are internal repositories and external repositories, depending on the system. Portal users can navigate in folders and access the items in the folders of all integrated repositories in an iView in the same way as on a file server. Access to folders and documents is controlled using permissions. The user interface for navigating in folders can be configured flexibly and modified to suit various roles. Users can personalize the presentation of the user interface. Open interfaces allow you to extend the user interface by integrating your own functions into the standard system Author: Subhendu Bikas Samanta Company: HCL Technologies Ltd., Kolkata Created on: 08 November 2007 Author Bio Subhendu Bikas Samanta is working in HCL Technologies Ltd, Kolkata as a NetWeaver Consultant.

Transcript of Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management...

Page 1: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 1

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

Applies to: SAP NetWeaver Developer Studio (NWDS) version 2.0.7 or 2.0.9 or 7.0.11 and SAP Web Application Server (WAS) version 6.40 or 7.0.

Summary Knowledge Management capabilities in SAP NetWeaver™ provides a central, role-specific point of entry to unstructured information from various data sources in the portal. This unstructured information can exist in different formats such as text documents, presentations, or HTML files. Workers in an organization can access information from different source such as file servers, their intranet, or the World Wide Web. A generic framework integrates these data sources and provides access to the information contained in them through the portal. Knowledge Management functions support you in structuring information and making it available to the correct target audience. These functions include search, classification, and subscriptions. You can use these functions on all content of integrated data sources, as long as the technical conditions are met. The repository framework of KM is the physical storage location for documents. It provides a range of basic functions for documents and folders. It enables the integration of documents into a virtual hierarchy and a namespace. The documents can be stored on different systems (Windows, WebDAV, or HTTP). Repository managers are used to access these systems. There are internal repositories and external repositories, depending on the system. Portal users can navigate in folders and access the items in the folders of all integrated repositories in an iView in the same way as on a file server. Access to folders and documents is controlled using permissions. The user interface for navigating in folders can be configured flexibly and modified to suit various roles. Users can personalize the presentation of the user interface. Open interfaces allow you to extend the user interface by integrating your own functions into the standard system Author: Subhendu Bikas Samanta Company: HCL Technologies Ltd., Kolkata Created on: 08 November 2007

Author Bio Subhendu Bikas Samanta is working in HCL Technologies Ltd, Kolkata as a NetWeaver Consultant.

Page 2: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 2

Table of Contents Applies to: ........................................................................................................................................ 1 Summary.......................................................................................................................................... 1 Author Bio ........................................................................................................................................ 1 Abbreviations Used.......................................................................................................................... 3 Prerequisite...................................................................................................................................... 3

Knowledge Requirements ............................................................................................................ 3 System Requirements.................................................................................................................. 3

Server ....................................................................................................................................... 3 Client......................................................................................................................................... 3

Software Component (API) Requirements................................................................................... 3 Implementation ................................................................................................................................ 4

Step1 : Create WebDynpro Application ....................................................................................... 4 Step2 : Configure the Application KM compatible ....................................................................... 7 Step3 : Design the UI of the Application ...................................................................................... 8 Step4 : Update the UI context using KM API to render the values in UI ................................... 15 Step5 : Navigate the repositories using Portal URL . ................................................................ 17

Run the Application........................................................................................................................ 18 Related Content............................................................................................................................. 19 Disclaimer and Liability Notice....................................................................................................... 20

Page 3: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 3

Abbreviations Used NWDS SAP NetWeaver Developer Studio WAS SAP Web Application Server KM Knowledge Management WD WebDynpro.

Prerequisite

Knowledge Requirements Core Java. Hands on experience on WebDynpro application. Overview of KM. Basics of KM Repository Framework.

System Requirements

Server SAP WAS 6.4 installed and configured on local or remote machine.

Client Install J2sdk 1.4.2_15 ( http://java.sun.com/j2se/1.4.2/install.html ). Install NWDS 2.0.9.

Software Component (API) Requirements bc.rf.framework_api.jar bc.rf.global.service.urlgenerator_api.jar bc.sf.framework_api.jar bc.util.public_api.jar com.sap.security.api.ep5.jar com.sap.security.api.jar prtapi.jar

Page 4: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 4

Implementation

Step1 : Create WebDynpro Application

Page 5: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 5

Check the Authentication checkbox to test the application from WebDynpro perspective (Right click on the application and run). Otherwise you have to create a WebDynpro iView and run the application from portal.

Page 6: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 6

Page 7: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 7

Step2 : Configure the Application KM compatible

Open Sharing Reference window from Project Properties select Web Dynpro References select the tab Sharing Reference Now put the PORTAL:sap.com/com.sap.km.application value into the input field.

Page 8: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 8

Set the JARs in the classpath by Add External JARs open from Project Properties Java Build Path Libraries Add External JARs.

Step3 : Design the UI of the Application First create the context node (KMContent) and attributes as shown below screen

Page 9: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 9

Now create 7 UI Elements as shown below

Page 10: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 10

Set the Element’s properties as depicted here

Page 11: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 11

Create an Action named Browse (shown below)

Page 12: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 12

Page 13: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 13

Page 14: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 14

Now the view screen looks like in NWDS as below

Page 15: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 15

Step4 : Update the UI context using KM API to render the values in UI Now you write the code written here to fetch the data from KM repository framework and store into context node and displayed on UI. public static void wdDoModifyView(IPrivateCompView wdThis, IPrivateCompView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime) { //@@begin wdDoModifyView IWDMessageManager msgMngr = wdThis.wdGetAPI().getComponent().getMessageManager(); IWDClientUser currentWDUser = null; try { currentWDUser = WDClientUser.getCurrentUser(); } catch (WDUMException e) { msgMngr.reportException("WDUMException: " + e.toString()); }

Page 16: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 16

IUser sapUser = currentWDUser.getSAPUser(); IUserFactory portalUserFactory = WPUMFactory.getUserFactory(); com.sapportals.portal.security.usermanagement.IUser ep5User = null; try{ ep5User = portalUserFactory.getEP5User(sapUser); IResourceContext context = new ResourceContext(ep5User); String resourceID = wdContext.currentContextElement().getCurrentFolder(); RID rid = RID.getRID(resourceID); IResource resource = ResourceFactory.getInstance().getResource(rid, context); if(resource.isCollection()) { ICollection collection = (ICollection)resource; IPrivateCompView.IKMContentElement contentElem = null; ArrayList arr = new ArrayList(); for(IResourceListIterator itr = collection.getChildren().listIterator(); itr.hasNext();) { IResource res = (IResource)itr.next(); contentElem = wdContext.nodeKMContent().createKMContentElement(); contentElem.setIslocked(res.isLocked()); contentElem.setName(res.getDisplayName(true)); contentElem.setModifiedby(res.getLastModifiedBy()); contentElem.setModifieddate(res.getLastModified()!= null?res.getLastModified().toLocaleString():""); contentElem.setUrl(generateUrlForIResource(res)); try{ contentElem.setSize(res.getContent().getContentLength()); contentElem.setType(res.getContent().getContentType()); }catch(Exception e){ msgMngr.reportSuccess(contentElem.getName() + " >> " + e.toString()); } arr.add(contentElem); } wdContext.nodeKMContent().bind(arr); } }catch(Exception e) { msgMngr.reportSuccess(e.toString()); } //@@end }

Page 17: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 17

You can navigate through repository by the below code when click on Browse Content column links. public void onActionBrowse(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ) { //@@begin onActionBrowse(ServerEvent) wdContext.currentContextElement().setCurrentFolder(wdContext.currentContextElement().getCurrentFolder() + wdContext.currentKMContentElement().getName() + "/"); //@@end }

Step5 : Navigate the repositories using Portal URL . You can navigate other ways also by portal URL. Portal URL generation is here. The generated URL is linked with the LinkToURL UIElement [Content Name column] private static String generateUrlForIResource(IResource resource) throws Exception { // Generate URL for a Resource IURLGeneratorService ugs = (IURLGeneratorService) ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.URLGENERATOR_SERVICE); IUriReference uriRef; uriRef = ugs.getRelativeUri(PathKey.CONTENT_ACCESS_PATH).appendPath( resource.getRID().toExternalForm()); return uriRef.toExternalForm(); } The code is setting the URL value to LinkToAction element when the view is generating from doModifyView method. contentElem.setUrl(generateUrlForIResource(res));

Page 18: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 18

Run the Application

Page 19: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 19

Browse Web folder and you can browse the folder as below

Related Content Knowledge ManagementSDN HelpSAP Help

Page 20: Navigate through Knowledge Management repositories and ......Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API SAP DEVELOPER

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 20

Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported 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 or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.