‎2006 Oct 31 2:37 PM
Hi,
I am downloading an excel file.
I have written a code like this.
If it is in foreground, it will display in ALV and download the data in an excel file in C:/ drive. IF i run in foreground i am getting the output and also the file is created in C:/ with the data.
If i run that program in background the file is not created. I am not able to see the file in C:/.
How to download a file in background..??
Kindly help meout plz..
Kumar
‎2006 Oct 31 2:39 PM
‎2006 Oct 31 2:43 PM
So, is there any solution for this issue. I need to do it as i do not have any other option.
Kumar
‎2006 Oct 31 2:51 PM
There is a way to download to PC from background, but you really have to jump thru some hoops and there is some stuff to be done on the PC itself. Really its not worth it.
There are a couple ways to work around this, but it depends on the real requirement. For example, say you have a long running report and the user wants to have the report in excel. So you need to run in background, you can run your report in backgroun and update a custom table with the data(or just write to the application server as a file), then the user can run a transaction after the job is completed to download the data to the PC, either from the custom db, or the application server.
Here is a short program which shows how to download a file from the application server to the frontend PC.
report zrich_0001.
parameters: p_file type localfile
default '/usr/sap/trans/data/R903289.TST'.
data: begin of idata occurs 0,
rec type string,
end of idata.
data: xdata type string.
data: stripped type rlgrap-filename.
data: file_path type rlgrap-filename.
data: fe_path type string.
start-of-selection.
* Download Data Files
open dataset p_file for input in text mode.
if sy-subrc = 0.
do.
read dataset p_file into xdata.
if sy-subrc <> 0.
exit.
endif.
idata-rec = xdata.
append idata.
enddo.
endif.
call function 'SO_SPLIT_FILE_AND_PATH'
exporting
full_name = p_file
importing
stripped_name = stripped
file_path = file_path.
concatenate 'C:' stripped into fe_path.
call function 'GUI_DOWNLOAD'
exporting
filename = fe_path
tables
data_tab = idata
exceptions
others = 22.Regards,
Rich Heilman
‎2006 Oct 31 3:10 PM
Thankyou all,
Anyway my problem is not solved, but got some reasons to put to my boss.. :-(..
Thankyou all...
Kumar
‎2006 Oct 31 3:22 PM
‎2006 Oct 31 2:43 PM
Hi ,
You cannot use WS_DOWNLOAD in background.
you can not use your presentation server links.that means that you will also not be able to use gui_download also.
Why dont you write your file to the application server and then download it using transaction CG3Y.
‎2006 Oct 31 3:49 PM
Hi Rich,
"There is a way to download to PC from background, but you really have to jump thru some hoops and there is some stuff to be done on the PC itself"
Please let me know the way to download to PC from background..Just to learn a new thing..
Thanks,
Naren
‎2006 Oct 31 4:05 PM
Hi Naren, here is the doc which lays it all out. Yes, it is possible(anything is with time and money) but is it a good idea?, maybe for an extreme case, but I think that we should still operate under the understanding that you can not download/upload using the standard SAP function modules from the background.
Regards,
Rich Heilman
‎2006 Oct 31 4:10 PM