cancel
Showing results for 
Search instead for 
Did you mean: 

how to download a file from Path specifed

Former Member
0 Kudos

Hi Frndz..

How to download a file from a specified path like , i have a file on server in the path like "C://temp/Sap.pdf"

I want to download this to user desktop..

Thanks in Advance

regards

Rajesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

try something like this

try {
  IWDResource res = WDResourceFactory.createResource(
    new FileInputStream("c:/temp/Sap.pdf"), "sap.pdf", WDWebResourceType.PDF, true);
  IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(
    res.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal()), 
    res.getResourceName());  
  window.show();
} catch (FileNotFoundException e) {	
  // ..
}

Bests

Answers (4)

Answers (4)

Former Member
0 Kudos

Use the function module :

CALL FUNCTION 'C13Z_APPL_TO_FRONT_END' for application server to front end.

and

CALL FUNCTION 'C13Z_FRONT_END_TO_APPL' for frontend to application server.

the report is as follows:

&----


*& Report ZNILFH

*&

&----


*&

*&

&----


REPORT ZNILFH.

start-of-selection.

CALL FUNCTION 'C13Z_APPL_TO_FRONT_END'

  • EXPORTING

  • I_FTFTYPE = 'BIN'

.

CALL FUNCTION 'C13Z_FRONT_END_TO_APPL'

  • EXPORTING

  • I_FTFTYPE = 'BIN'

.

end-of-selection.

Former Member
0 Kudos

answred

jnmurthi
Participant
0 Kudos

hi

ply try going through the following link to get an idea on working widh file download UI

[file download and upload UI|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f]

FileDownload

With the FileDownload element, the user can download a file. Depending on the selected setting of the behaviour property, the user can open the file or store it on the local hard disk.

The data source, that is the file to be downloaded is determined by the resource property. To be able to load a file into the context with the FileDownload element, you need the WDResourceFactory. Insert the following code into the wdDoInit method:

IWDResource resource = WDResourceFactory.createResource(new byte[<number of bytes>], "<name of the file>", WDWebResourceType.<type of the file>);

wdContext.currentUiResourceElement().setResource(resource);

currentUiResourceElement depicts the context node under which you have created the value attribute resource of type Resource.

regards,

Murthi.

PradeepBondla
Active Contributor
0 Kudos

Hi,

For file down load u have to use a UI element as "File download".

u just create context attribute as setdownload_res and file data.

setdownload_res as of type "com.sap.ide.webdynpro.uielementdefinitions.Resource" then bound it to the ui element "resource".

file data as of type "com.sap.tc.webdynpro.progmodel.api.IWDInputStream"

and set calcuclated as true and read only as true.

then in doinit method u just write this code

IWDAttributePointer attr = wdContext.currentContextElement().getAttributePointer("fileData");

IWDResource res = WDResourceFactory.createResource(attr,null,WDWebResourceType.UNKNOWN);

wdContext.currentContextElement().setDownload_res(res);

wdComponentAPI.getMessageManager().reportSuccess(""+c);

after this in the getter method u write this code

IWDInputStream stream = null;

try

{

stream = WDResourceFactory.createInputStream(new FileInputStream(new File("<pathof the file to be download>")));

}

catch(Exception e)

{

e.printStackTrace();

}

return stream;

also look at this thread

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081...

PradeeP

Former Member
0 Kudos

Hi ..

Thanks for ur promt reply,i tried with ur code ,but in getter method itz throwing an error in the retuen statement that WDResource can't convert into WDInputStream.

Plz suggest me another solutioon or rectify this

Thnaks in Advance

Regards

Rajesh

Former Member
0 Kudos

Hi Frnd..

Thank u very much yaar, with ur code my problem got resolved...Thanks a lot

Regards

Rajesh