Creating a KM Folder Programmatically

Header-Design Augmentation

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

Give the appropriate name and click on Finish.


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\\irj\servlet_jsp\irj\root\WEB-INF\portal\ (for example: c:\usr\sap\F48\JC30\j2ee\cluster\server0\apps\\irj\servlet_jsp\irj\root\WEB-INF\portal\)


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


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.

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

try {

IWDClientUser WDClientUser = WDClientUser.getCurrentUser(); sapUser = WDClientUser.getSAPUser(); 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);
//ILink link = parent.createLink(″link″, ″/documents/file″, LinkType.INTERNAL, null);

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

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)

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 :

(We promise a no-obligation consulting reply)