cancel
Showing results for 
Search instead for 
Did you mean: 

Where does the word document store?

Former Member
0 Kudos

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.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a...

Thank you.

Regards,

Henry

Accepted Solutions (0)

Answers (1)

Answers (1)

sanyev
Active Participant
0 Kudos

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

Former Member
0 Kudos

Hi Sanyev,

Yes, I understand the file is store in the context. But what do you mean I have the option to choose to store the file according to the requirement.

Where and how can I access the option to choose to store?

Thank you.

Regards,

Henry

sanyev
Active Participant
0 Kudos

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

Former Member
0 Kudos

Hi Sanyev,

Thanks for your information.

Can you give me a sample of the java IO code on writing the file to the server?

Thanks.

Regards,

Henry

sanyev
Active Participant
0 Kudos

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