on 04-30-2009 1:31 AM
Hi Expert,
Using webdynpro java to upload the file, where does the file actually store?
I refer to below tutorial but have no ideal where the file is store. Please help.
Thank you.
Regards,
Henry
Hi Henry,
If you are using the FileUpload UI element the file will be uploaded to the IWDResource attribute in your context. The same attribute that you bind your FileUpload UI element. Once you reach the action handler of the FileUpload UI element the file will be available in your context attribute. Now you can choose to store the file according to requirements. Mosly people would want to store the file in KM repository or would like to store in the R/3 system. For storing the file in the R/3 system you need a function module or BAPI capable of storing the file in the R/3 system.
Regards,
Sanyev
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Henry,
Once you reach the Action handler of the FileUpload UI Element your file has already been uploaded and is available in your context attribute. Now depending on the requirement you need to store the file.
If you need to store the file in a shared location then you need to write the file to that location using normal java I/O.
IWDResource resource = element.getMyResAttr();
InputStream is = resource.read(true);
try
{
/* read bytes from stream and write it to file */
}
finally
{
try { is.close(); } catch (final IOException ex) {}
}
If you need to store the file on the R/3 system then you need to call the function module/BAPI capable of doing so and pass the resource file to the function module. Some times you might need to convert the IWDResource file to a byte array. The code given above can be modified to do that. If there are no function modules or BAPI's capable of storing the Word Document available you will have to write one.
Let me know if this helps.
Regards,
Sanyev
Hi Henry,
The code should look something like this.
IWDResource resource = element.getMyResAttr();
InputStream inputStream = resource.read(false);
try
{
String fileName = "Path to the server shared location";
File destfile = new File(fileName);
FileOutputStream out = new FileOutputStream(destfile);
if (inputStream != null)
{
int c;
while((c = inputStream.read()) != -1) {
out.writeByte(c);
}
out.close();
}
}
finally
{
try { is.close(); } catch (final IOException ex) {}
}
Hope this helps.
Regards,
Sanyev
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.