Skip to Content
This weblog is meant as a follow up to the original weblog by Prakash Singh of Universal Systems Technologies, Inc. The core code described in this weblog was written by Prakash, who has given me permission to write this weblog on his behalf. This is also a tool I use at work as it has saved me significant manual work when transporting (or migrating) KM content between development, test/QA and production environments.

A bit of background to begin. I recently posted a question in the forums concerning whether there was an automated way to recursively navigate within a folder in KM and replace text strings in target URLs of external links. I got a very useful reply by Prakash Singh, a growingly popular SDN member. He’d advised me to use the code I will describe later, and further to that went the extra mile to contact me by phone and assist me to actually build the project and compile the resulting PAR using SAP Netweaver Dev Studio. ‘Pretty cool, eh? This is the type of collaborative effort SDN members have made that make SDN such an effective resource to the SAP customer base.

Now, to the code. Firstly, please refer to the weblog Prakash wrote earlier concerning building an HTMLB tree using recursive logic, as follows:

Build Your Own KM Navigation iView Using HTMLB Tree

Taking some of the learning in Prakash’s weblog, you can now apply the same logic to modifying target URLs of external links. Building a new project, make sure to add the libraries that are part of the SAP NetWeaver Dev Studio installation in the path:

{SAP NetWeaver Dev Studio Installation Folder}

And, libraries in the path you can locate from the Ep6 portal server:

{Ep6 Portal Server path}appssap.comirjservlet_jspirj

Then, in your code, ensure you’ve the following import lines before you proceed:

Next, you will want to declare three String variables: strPath, strSearch and strReplace. These will need to be assigned through your interface, or as properties within your ‘portalapp.xml’ file which your retrieve through a profile object, or however you wish. Those will then be used by the two methods that will perform the actual search and replace.

Now, include the following two methods within your application:

Now, you’ve an application that can perform a recursive search and replace in KM. That is, it will modify any external links within a given path (such as ‘/documents’) and search and replace strings you specify within the target URL property of the external links that are found. I’ve a little tool in the works that combines this code into a proper Portal application (with a GUI, that is). I’ll try and get that uploaded after the SDN Meets Labs event next week. Thanks to Prakash Singh for the great code and guidance. I hope you find this helpful. I’ve already been notified that someone has enquired about applying this logic towards modifying metadata in KM documents. The code would be very close to what is included here, with exception to referencing the KM objects not as links but as resources with specific properties.

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

    1. Viswanath Naidu Post author
      Thanks Prakash,

      I could not have done it without your help.  You’ve been a very positive contributor to SDN, and based on the feedback on your weblogs, you give users what they want – straightforward solutions that can be implemented with very little effort.  Keep up the great work.  You’ve raised the bar of excellence.  I hope I can reach that quality in the future.

      1. Pablo Lopez
        Hi, it is very good code, but it is very time consuming when you have more than 2000 documents. Isn’t it better to user the FederatedSearch to retrieve the resources?? Thanxs
        1. Viswanath Naidu Post author
          Hi Pablo,

          Thanks for the feedback.  I agree it is very slow.  I’ve not heard about the FederatedSearch function/feature.  Could you kindly elaborate?  Then, we can possibly collaborate to create an updated and optimized version of this tool, and share it with the rest of the SDN community.  Much appreciated!



Leave a Reply