cancel
Showing results for 
Search instead for 
Did you mean: 

How to save table to file in Mobile 7.1

Former Member
0 Kudos

Hello,

We are using Mobile 7.1. We are trying to save the table context in the mobile client to the local file.

We use a FileDownload element in the screen. The FileDownload is bound to a Resource attribute which contains the table data (as well as name and type of the file).

When the user clicks on the FileDownload link, he gets an error message "Cannot open HTTP connection" with an http link that points to the file.

Do you know how can we save the table context to the client (i.e. export to excel)?

If it's impossible with FileDownload, is there a way to open a Save As dialog and write the file locally? (We don't know how to open the Save As dialog from web dynpro).

Thanks in advance,

Sergey

Edited by: Sergey Kozyrev on Dec 23, 2008 11:05 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi,

The http link that is used in the FileDownload should be in the following format :

https:
localhost ......

In 7.1 the file can only be downloaded the following way:

get the deployable part :

use a fileInputstream element to read contents of the file.

Then :

WDDeployableObjectPart dom = wdThis.wdGetAPI().getComponent().getDeployableObjectPart();

IWDCachedWebResource res;

res = WDWebResource.getPublicCachedWebResource(in, WDWebResourceType.TXT[whatever you need as the file extension], WDScopeType.APPLICATION_SCOPE, dom, "Attachment");

Thanks and Regards,

Narayani

Former Member
0 Kudos

Hello Narayani,

Thank you for your help. The class you gave had better results, but it's still not the solution.

What we get now is that the file opens but in an internal viewer, even though the FileDownload is set to "Allow Save".

Furthermore, the file we generate is an XML file that opens in excel, but in the internal viewer it seems like gibrish (maybe it tries to interpret it as a binary file).

How can we make it open in excel (or open the Save As dialog)?

Another question is that we used the other API for on-demand file download (instead of creating the file every time the user enters the screen we wanted it to be created only when the user clicks the link). This is possible in normal web dynpro:

[http://help.sap.com/saphelp_nw2004s/helpdata/en/42/f6ec5a09321bc7e10000000a11466f/content.htm]

Is it impossible in mobile web dynpro?

Sergey.

0 Kudos

Hi,

The XML file seems garbled because you are trying to open it in excel which it doesnot understand.

You can try an open it in the IE/or any other browser. You can try using the run command used in java.

http://help.sap.com/saphelp_nw2004s/helpdata/en/42/f6ec5a09321bc7e10000000a11466f/content.htm

is not possible in Mobile webdynpro.

You can upload the file in the backend as a binary file, and then send it to the client, open it in the client the way you require.

Thanks and Regards,

Narayani

Former Member
0 Kudos

Hello Narayani,

Excel undestands the xml format that I send. We use the same format in other web dynpro applications (not mobile) and it works. That format is explained in the document:

[https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/edc2f3c2-0401-0010-8898-acd5b6a94353]

If we save the file (open the url in IE and use save as...) and open it excel, it looks well-formatted. It is only the internal viewer in the mobile client which does not understand the file, and that is why I want the file to open in excel or (preferrably) open the file save as dialog.

What do you mean by upload the file in the backend, send it to the client and open it? How can we open it the way we require?

Sergey.

Former Member
0 Kudos

I found a way to solve the problem:

Instead of using a FileDownload element, I used a LinkToAction element. On the action I generate the excel resource file (this way it's also on-demand), and call the WDResource.download() method (with WDFileBehaviour.ALLOW_SAVE.ordinal() parameter). Then the user can save the file wherever he wants.

Sergey.

Former Member
0 Kudos

Hi Sergey/Narayani,

Right now I'm having problems with mobile reports. I need to create som printable reports in some format like PDF, Plain Text, etc. But my problem is how to create that in JDK 1.5 without external libraries. In a normal java project I can import some libraries with no problem, but in a WebDynpro Mobile for laptops I cant, because it's a DC's. Can anybody help me with this issue.

Regards,

David Faustini