Skip to Content
Author's profile photo Pramod Gopisetty

KM Scheduler Task for copying files to KM Folder

Scheduler Task that runs on specified time and push the files from Folder on Portal server to KM Folder.

After upgrading our Portal landscape from 7.02 to 7.4, existing Scheduler task stopped working.

Just migrating the .par file from 7.02 to .ear file in 7.4 would resolve the issue. But life is never so simple right 🙂 …

This blog is to help everyone who have similar requirement.

1. Before starting development, do the steps below :

    (a) Download refer to SAP Note 1572813 and extract the files to NWDS – Plugins as below

          File Location.jpg

      (b) Follow the Document How_To_Guide_for_KMC_Plugins_NW73.pdf and create the project.

2. Once done with creation of Project in NWDS, you should be seeing Project Content as below:

    Project Content.JPG

3. Open the file and add the code below:

In the Code, In the Key = replace with the Name of the ‘SchedulerTask’, in this case the name of the Java file which actually contains your code on what the scheduler task does.


4. Make sure you are adding the required Jar files in Build Path.

5. Open the file and do the coding

Scheduler Task Code.JPG

Here the Property “SAPINFO” will get you the server name where the scheduler task is running.

In my case, I have the files in Folder  OrganizationChart and want to move the files to folder /documents/ESS

Below code goes and reads the files in folder OrganizationChart

Code Continuation:


  server = “Development Portal”; (don’t need to give FQDN)

File dir = new File(“\\\\” + server + “\\OrganizationChart”); user =

  WPUMFactory.getServiceUserFactory().getServiceUser(“cmadmin_service”); (All KM Content uses user cmadmin_service for connecting to system to read                                                                                                                        the files)

  com.sapportals.wcm.repository.IResourceContext resourceContext = new ResourceContext(user);

int fileStatusCounter = 0;

  try {

  IResourceFactory factory = ResourceFactory.getInstance();

  com.sapportals.wcm.repository.IResourceContext context = new ResourceContext(user);

  RID repositoryid = new RID(“/documents/ESS/”);

  ICollection parent = (ICollection)factory.getResource(repositoryid, context);

  File files_in_folder[] = dir.listFiles();

  int number_of_files = files_in_folder.length;

  for(int i = 0; i < number_of_files ; i++)


  StringTokenizer token1 = new StringTokenizer(files_in_folder[i].getName(),”.”);

  String extension;

  for(extension = “”; token1.hasMoreTokens(); extension = token1.nextToken())


  if(!”htm”.equalsIgnoreCase(extension) && !”js”.equalsIgnoreCase(extension) && !”html”.equalsIgnoreCase(extension))


  FileInputStream sourcefileforinput = new FileInputStream(files_in_folder[i].getAbsolutePath());

  com.sapportals.wcm.util.content.IContent filecontent = new Content(sourcefileforinput, null, -1L);

  IResource resource1 = ResourceFactory.getInstance().getResource(RID.getRID(“/documents/ESS/” + files_in_folder[i].getName()), context);

  resource1.updateContent(filecontent);  //(For Updating the files already existing in the folder)

  //com.sapportals.wcm.repository.IResource resource = parent.createResource(files_in_folder[i].getName(), null, filecontent);  //(for creating file if no file exist,                                                                                                                                                                                              use which ever is applicable)





  catch(ResourceException ex1)






catch(Exception ex)






6. All the KM Scheduler Task related Projects are Hot-Deployment, meaning you need to restart Portal to see the changes.

7. After Restart, in Portal navigate to System Administration – System Configuration – Knowledge Management – Content Management – Global Services – Scheduler Tasks –


8. Click on Task and assign the CM Systems and Time when to run the Scheduler.


SAP Note: 1572813 to install KMC Plug-in for NWDS 7.3


NWDS Version 7.3

SAP Portal 7.4 SP6

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Kai Unewisse
      Kai Unewisse

      KM Scheduler are useful, but the have the issue that the portal has to be restarted.

      This means, that updates can be only applied with a downtime.

      An alternative is a Netweaver Scheduler: SAP NetWeaver Scheduler for Java -  Using Central Development Services - SAP Library

      Author's profile photo BHARANIDHARAN S P M

      How to check whether the custom task is running or not. Also is there any way to get reports that the task was running ?