Skip to Content
avatar image
Former Member

Reading txt file from KM

I have a file located in KM that I wanted to read, and based on the content (numbers - one on each line), I create my logic of what to display. I have read a lot of the threads and blogs on how to connect and read from KM, but I seems like I can't get to the document.

Whenever I try to deploy the code to test, my DTR rejects it because it doesn't find the .JAR's even though I've added them according to the document "Using Knowledge Management Functionality in Web Dynpro Applications"

Could someone point to a good document to go to or something? What are the steps to go though for accessing a document in KM?

Thank you.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jun 23, 2009 at 02:55 AM

    Hi,

    Are you working in Development Component?

    Because if so you might need to create an External Library DC for the jars that you need to add and then add them as Used DC to your current DC.

    Refer to the following link:

    http://help.sap.com/saphelp_nw04s/helpdata/en/5a/2e2f4234135433e10000000a155106/content.htm

    Regards.

    Rajat

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      >

      > Hi,

      >

      > Are you working in Development Component?

      > Because if so you might need to create an External Library DC for the jars that you need to add and then add them as Used DC to your current DC.

      >

      > Refer to the following link:

      > http://help.sap.com/saphelp_nw04s/helpdata/en/5a/2e2f4234135433e10000000a155106/content.htm

      >

      > Regards.

      > Rajat

      I've gone through this document before, but my DTR still rejects it when I try to activate it.

  • avatar image
    Former Member
    Jun 23, 2009 at 05:23 AM
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Sana,

      Can you please try this code.

      RID rid = RID.getRID("/documents/testext.txt");
      try { 
           com.sapportals.wcm.repository.IResource resource = ResourceFactory.getInstance().getResource(rid, resourceContext);
      if (resource != null) {
      String str = null;
      String text = "";
      
      BufferedReader in = new BufferedReader(new InputStreamReader(resource.getContent().getInputStream()));
      while ((str = in.readLine()) != null) {
      text+ =  str+"\n";
      }
      wdContext.currentTextElement().setText(text);
      }
      } catch (RuntimeException e2) {
      // TODO Auto-generated catch block
      }
      

      I hope this should solve your issues. Please revert back in case you need any further help on this.

      Thanks and Regards,

      Pravesh

  • avatar image
    Former Member
    Jun 24, 2009 at 12:45 PM

    Thank you for the code, but my trouble is not the code, I can get that and it works on my local machine(somewhat). When I test my code on my local machine, its signing in to KM as "Guest", so, I need to test on the portal, but when I go to deploy my code, DTR wont let me activate it because it can't find the .Jar files I'm using. And I did set up an external library dc, and I am referencing it in the "used dc" portion of my DC. What I can't understand is why it wont find the .jar files, and if I'm missing something.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I didn't understand why you are not able to actiavte it.

      I have also created an external library DC for this KM API Jars and added this jars to public parts both for compile time and run time, and used this public parts in my webdynpro DC....

      I have given the sharing reference in my webdynpro DC : PORTAL:sap.com/com.sap.km.application

      Its working for me...

      But for external libraries check wether you have followed all the steps mentioned in this blogs..

      /people/bala.krishnan2/blog/2006/09/25/bid-adieu-to-bots--using-captchas

      /people/bertram.ganz/blog/2008/11/24/how-to-use-external-jar-files-in-web-dynpro-development-components

      Go through this blog also...

      /people/rohit.radhakrishnan/blog/2005/05/27/uploading-files-to-km-repository-using-webdynpro-apis

      Regards,

      Saleem

  • avatar image
    Former Member
    Jun 24, 2009 at 02:22 PM

    I did look at the document and yes, I am referencing the km in shared references.

    Add comment
    10|10000 characters needed characters exceeded