cancel
Showing results for 
Search instead for 
Did you mean: 

Log file creation using km api

former_member442169
Participant
0 Kudos

Hi,

how to create log file using km api . please provide me if any sample code available.

Thanks and Regards,

Nari.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member442169
Participant
0 Kudos

problem resolved by self.

Former Member
0 Kudos

Dear Narikk,

We are also facing the same problem.

Could you please help us how you have resolved the problem.

Your suggestion will be highly appreciated.

Warm Regards,

Upendra Agrawal

p330068
Active Contributor
0 Kudos

Hi Nari,

Please have a look at [Knowledge Management using WebDynpro |http://wiki.sdn.sap.com/wiki/display/Snippets/UpdateKnowledgeManagementusingWebDynproJavaApplication]

Yon can create text file in wd Java and placed in the KM using KM API

Hope it helps

Regards

Arun

former_member442169
Participant
0 Kudos

Hi Arun,

How can i use km api in PDK Applications.By adding jar files coding part completed but run time exception accrued i think it needs to add some reference like web Dynpro applications(PORTAL:sap.com/com.sap.km.application).please tell me procedure if u know.

Thanks and regards,

surya.

Former Member
0 Kudos

Hi Narikk,

You have to edit portalapp.xml file.

for example:-<?xml version="1.0" encoding="UTF-8"?>

<application>

<application-config>

<property name="SharingReference" value="usermanagement, knowledgemanagement, landscape, htmlb, exportalJCOclient, exportal,com.sap.km.cm, com.sap.portal.pcm.admin.apiservice, com.sap.portal.pcd.glservice"/>

<property name="ServicesReference" value="com.sap.portal.ivs.api_iview, com.sap.portal.ivs.api_landscape, SAPJ2EE::library:tckmcbc.uwl~api"/>

<property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>

</application-config>

<components>

<component name="Email">

<component-config>

<property name="ClassName" value="com.amat.Email"/>

</component-config>

<component-profile>

<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>

</component-profile>

</component>

</components>

<services/>

</application>

Hope this may help you.

Deepak!!!

former_member442169
Participant
0 Kudos

Thanks for your quick reply but one more requirement is... here i can able create text file in km and adding content to created text file on the same line but i want to update new content in next line(newline).Please see below code and correct it.


	Date dt = new Date(Calendar.getInstance().getTimeInMillis());
						com.sapportals.portal.security.usermanagement.IUser iuser = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
						IResourceContext irCtx = new ResourceContext(iuser);
						RID docsResource = RID.getRID(filepath);
						IContent initCont = new Content(new ByteArrayInputStream("".getBytes()),"text/plain",-1,null);
						
						if(ResourceFactory.getInstance().getResource(RID.getRID(filepath+"/"+filename), irCtx) == null)
						{
							ICollection docsColl = (ICollection)com.sapportals.wcm.repository.ResourceFactory.getInstance().getResource(docsResource,irCtx);
							docsColl.createResource(filename,null,initCont);
						}
					 String InputData = Exception;
			
					 RID sugg_html = RID.getRID(filepath+"/"+filename);
					 IResource resource = com.sapportals.wcm.repository.ResourceFactory.getInstance().getResource(sugg_html,irCtx);
			
					 String existingComments;
			
					 IContent cont = resource.getContent();
			
					 BufferedReader buf_in = new BufferedReader(new InputStreamReader(cont.getInputStream()));
			
					 existingComments = buf_in.readLine();
			
					 existingComments = existingComments+"   "+"\n"+dt+InputData;
			
					 ByteArrayInputStream inputStream = new ByteArrayInputStream(existingComments.getBytes());
					 cont = new Content(inputStream,"text/plain",-1,null);
			
					 resource.updateContent(cont);
			
					 cont.close();

p330068
Active Contributor
0 Kudos

Hi Surya,

Please refer to below documents for adding refrences http://help.sap.com/saphelp_nw70/helpdata/en/1f/26b742cafec96ae10000000a155106/frameset.htm

/docs/DOC-8557#section17 [original link is broken]

Hope it helps

Regards

Arun

Former Member
0 Kudos

Hi Narik,

In the Text file use can not use "\n" for new line, it will not work.

You can do few thing:-

1>try to save .doc file in KM, in place of text file. Then "\n" will work as per your requirment.

2> user "\t" tab and format the file .txt file.

I have written below simple java program to write in a file:-

public class TestingJava {

* *

* *

* public static void main( String [] args ) throws Exception*

* {*

* try {*

* BufferedWriter out = new BufferedWriter(new FileWriter("c://ep docs/hello.doc"));*

* out.write("aString \n hello");*

* out.close();*

* } catch (IOException e) {*

* }*

* *

* }*

}

Try this code and change file type in the path;-c://ep docs/hello.doc to better understanding...:)

Hope this may help you.

Deepak!!!

Edited by: Deepak Arora on Apr 22, 2010 8:47 AM

former_member442169
Participant
0 Kudos

Hi Deepak,

Thanks for your reply, .doc file "\n" is accepted but it is first time only means if i try to update content at run time second time onwards it's not updated.

Bufferedwriter used for file system api only but here i'm using km api.

Thanks and regards,

nari