Over View:

We are going to create a new folder in KM using Web dynpro java.We can create the folder in the KM manually , our aim is to create the folder programmatically through Web dynpro java using KM API’s.

Step1 : Creating Web dynpro Project
Open NWDS –> File –> New –> Web dynpro Development Component

Creating a KM Folder Programmatically

Creating a KM Folder Programmatically

Give the appropriate name and click on Finish.

KM

KM

We need to set the two class path variables.Choose Window–> Preferences –>Class path
variable and click on New
1. Give the name as WEBAS_HOME and provide the following path \usr\sap\\JC\j2ee\cluster\server (for example: c:\usr\sap\F48\JC30\j2ee\cluster\server0)
2. Give the name as PORTAL_HOME and provide the following path WEBAS_HOME\apps\sap.com\irj\servlet_jsp\irj\root\WEB-INF\portal\ (for example: c:\usr\sap\F48\JC30\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\WEB-INF\portal\)

KM

KM

After giving the class path variable we need to set Java Build path. Right click on the project –>properties –> Add Variable
We need to add the following jars
1.prtapi.jar
2.comman_api.jar
3.framework_api.jar
4.util_api.jar
5.urlgenerator_api.jar
6.public_api.jar
7.com.sap.portal.service_api.jar
8.com.sap.portal.usermanagementapi.jar
9.com.sap.security.api.ep5.jar

KM

KM

And in the web dynpro references tab we need to insert the following path.For opening Web dynpro references right click on the project–>select properties–>select web dynpro and select sharing References as shown in the below screen shot.
PORTAL:sap.com/com.sap.km.application

KM4

Write the following code to Creation of new folder and uploading the files into KM

try {

IWDClientUser WDClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = WDClientUser.getSAPUser();
com.sapportals.portal.security.usermanagement.IUser epUser = WPUMFactory.getUserFactory().getEP5User(sapUser);
// wdComponentAPI.getMessageManager().reportSuccess(epUser.toString());
IResourceContext context = new ResourceContext(epUser);
RID rid = RID.getRID(“/documents”);
ICollection parent = (ICollection)ResourceFactory.getInstance().getResource(rid, context);
IResource resource = parent.createResource(“file”, null, null);
ICollection collection = parent.createCollection(“folder”, null);
wdComponentAPI.getMessageManager().reportSuccess(“uploaded”);
//ILink link = parent.createLink(″link″, ″/documents/file″, LinkType.INTERNAL, null);

} catch (ResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WDUMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserManagementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Finally build and deploy the project.login to the portal for the creation of the Web dynpro for java Iview.
Go to Content Administration and create new –>Iview and select the appropriate component and finally click on finish to create the Iview.

 

Need Help:

In case you need assistance on SAP Support Services, please contact us. Please send us your questions, comments or assistance request and our team would be glad to assist you.

By Anil Kumar (on behalf of SAP Consulting Team)


Apprisia
SAP :: Streamlined

We offer variety of services including SAP ECC ,SAP HR,SAP BW,SAP CRM, SAP SCM,SAP BPM, Business Objects, SAP ABAP DevelopmentSAP BASIS and SAP NetWeaver consulting. We have expertise in providing implementation, development, SAP Migration and SAP support services to SAP customers across diverse industries at a global level.

Have a question on SAP? Write to our SAP Architect : AskTheArchitect@Apprisia.com

(We promise a no-obligation consulting reply)