cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing knowledge management documents using webdynpro for java

Former Member
0 Kudos

Dear all,

iam having some documnets in KNLOWLEDGE MANAGEMENT documents folder in portal using webdynpro for java clicking on a link means perner(employee no) i should get that perpicular employee number documents.

examples documents are stored like this in knowledege management folder 20016319.pdf , 20016397.pdf , 20016398.

how to access those employee using webdynpro for java for perticular employee number if i want 20016319

Send me the code for above requirement and where i have to wrirte that code exactly

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dear Kishore,

As you have have said that the documents are stored according to the employee number, so the easiest way (code free) to do this would be using a Link to URL Ui element, and in the properties of this UI you can provide the URL of the document which is saved in the KM.

For this you can create a value attribute of type string and set it with the address of the KM folder concatenated by the employee number, and bind it to the Link to URL UI.

Hope it helps!!

Warm Regards,

Upendra Agrawal

Former Member
0 Kudos

Dear upendra ,

iam using following code in doinit to access employee document if iam having 1000 thousand from that if i want perticular employee documnet without hard coading the employee number as shown below

wdContext.currentContextElement().setCa_pernr("37101112");

wdContext.currentContextElement()

.setCa_text

("http://sreolllqel:59990/irj/go/km/docs/documents/FORM16/" +

wdContext.currentContextElement().getCa_pernr() +

".html");

Edited by: kishore shikore on Mar 3, 2010 11:44 AM

Edited by: kishore shikore on Mar 3, 2010 11:58 AM

Former Member
0 Kudos

Dear Kishore,

Are you having problem in getting the employee pernr??

Warm Regards

Upendra Agrawal

Former Member
0 Kudos

Dear kishore,

You can use the below example KM path. you can store the perner in the following example code and define the below KM path and iterate KM repository then you can access the KM document


String employee=wdContext.currentContextElement().getetCa_pernr;
KM path = "/documents/Employee folder/employee";

Regards,

Manivannan P

Edited by: manivannan palanisamy on Mar 3, 2010 12:11 PM

Former Member
0 Kudos

Dear upendra yes.

In form16 folder iam having lot of documnets with perner using webdynpro for java i have to get those documents for that perticular employee from knowledge managemnet document folder using webdynpro for java

Regards

Edited by: kishore shikore on Mar 3, 2010 12:21 PM

Edited by: kishore shikore on Mar 3, 2010 12:22 PM

Former Member
0 Kudos

Dear Kishore,

To get the Employee ID you have to create a Adaptive RFC Model (call BAPI) which will return you the employee pernr, for this

1. Create a model using : BAPI_EMPLOYEE_GETDATA

2. Get User ID using the code

public java.lang.String getUserID( )
  {
    //@@begin getUserID()
	String userID = new String();
		try 
		   {
			 // getting Logged in userid
			IWDClientUser myUser = WDClientUser.getCurrentUser();
			userID = myUser.toString().substring(19).trim();
			StringTokenizer filterdUID = new StringTokenizer(userID,")");
			userID = filterdUID.nextToken();
			}
		catch (WDUMException e) 
			{
			e.printStackTrace();
			}
			return userID;
    //@@end
  }

3. Execute the BAPI


 public java.lang.String getEmployeeID( java.lang.String userID )
  {
    //@@begin getEmployeeID()
	String employeeID = new String();
		Bapi_Employee_Getdata_Input employeeData = new Bapi_Employee_Getdata_Input();
		Bapi_Employee_Getdata_Output outData = new Bapi_Employee_Getdata_Output();
		Bapip0105B comm = new Bapip0105B();
		com.sap.aii.proxy.framework.core.AbstractList list = new Bapip0105B.Bapip0105B_List();
		list.add(comm);
		employeeData.setUserid(userID);
		Calendar cal = Calendar.getInstance(Locale.UK);
		Date date = new Date(cal.getTimeInMillis());
		employeeData.setDate(date);
		employeeData.setAuthority_Check("");
		employeeData.setCommunication(list);
		outData.addCommunication(comm);
		wdContext.nodeBapi_Employee_Getdata_Input().bind(employeeData);
		wdContext.nodeOutput_BAPI().bind(outData);
	   try
		{
			wdContext.nodeBapi_Employee_Getdata_Input().currentBapi_Employee_Getdata_InputElement().modelObject().execute();
			wdContext.nodeOutput_BAPI().invalidate();
	   } 
	   catch (WDDynamicRFCExecuteException e) {printMsg("Failed to Obtain Employee Data");
		   e.printStackTrace();
	   }
	   employeeID = wdContext.nodeBapi_Employee_Getdata_Input().nodeOutput_BAPI().nodeOrg_Assignment().currentOrg_AssignmentElement().getPerno();
	   return employeeID;
    //@@end
  }

Hope it Helps!!

Warm Regards

Upendra Agrawal

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Kishore,

I have used the following code to access files in a folder of KM. I think you can make some changes to the code and use it for your requirements. I hope this helps you.

		
try {
  com.sapportals.portal.security.usermanagement.IUser
   ep5User = WPUMFactory.getServiceUserFactory().getServiceUser(QUICKLINK_USER);
  ResourceContext context = new ResourceContext(ep5User);
 
  /*Give the path to KM in the variable path */
  RID rid = RID.getRID("folder/path");
  IResourceFactory factory = ResourceFactory.getInstance();
  ICollection folder = (ICollection) factory.getResource(rid, context);
 
  IResource resource = ResourceFactory.getInstance().getResource(RID.getRID("folder/path/file.xml"), context);	
 
  if (resource != null) {
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = dbFactory.newDocumentBuilder();
    Document document = builder.parse(resource.getUnfilteredContent().getInputStream());
 
    // Here you can do your XML Stuff
  else {
    // File not found error handling goes here
  }

Also have a look at the following thread. It might be helpful for you.

/message/8597189#8597189 [original link is broken]

Regards,

Gopal.