on 06-20-2005 11:22 AM
Hi,
I am new user to webdynpro and has the task of reading data from XML file.The file is created using XML form Builder and is stored at a location.But my code gives me the path instead of the content in the data.
The code is :
try
{
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
// create an ep5 user from the retrieved user
IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
IResourceContext context = new ResourceContext(ep5User);
/Specify the path of ur document here./
RID pathRID = RID.getRID("/documents/70f51182-84c3-2710-ce91-8d5fbfde713d.xml");
//RID pathRID = RID.getRID("/documents/hol.txt");
wdContext.currentContextElement().setSetDisp(pathRID.toString());
IResource resource = ResourceFactory.getInstance().getResource(pathRID, context);
InputStream in = resource.getContent().getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int bytesread = 0;
while ((bytesread = in.read(buffer)) != -1)
{
out.write(buffer, 0, bytesread);
}
String myData = out.toString();
/*myFile will containS the content of the document./
wdContext.currentContextElement().setSetDisp(myData);
}
catch (Exception e)
{
// wdContext.currentContextElement().setTextdisp("IO Error:" + e.getMessage());
}
text data is read from the location but XML data is not read.
Please help me out.
Hi Shriram,
I also have same req and facing the same problem.
Did you solve it?
Actually I am able to read the file on to a window. But if i am try to set that to a field on view, I am getting a some path instead of the content.
If you got the solution Please post it.
thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi SriRam,
For some reasons you are not able to change the value of attribute SetDisp ahich you gave the default value as the path using the following statement
wdContext.currentContextElement().setSetDisp(myData);
Remove that line.First try to open the files using creating new window instance
IWDWindow window =
wdComponentAPI.getWindowManager().createExternalWindow(
"http://<server name>:<port no>/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs"
+ "/documents/Public Documents/...."
+ "/"
+<name>,
"from km repository",
false);
window.open();
Then we can be sure that the error is due to reading data using input stream
Regards
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shriram,
seems that the path name comes from
wdContext.currentContextElement().setSetDisp(pathRID.toString());
while the line
wdContext.currentContextElement().setSetDisp(myData);
seems not to be reached?!
Did you try to kill the first of both? What's the output then? And uncomment the content of the catch block.
Best regards
Detlev
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.