file download to PC in background
Hi,
Does anybody know if there is a way to download a file to PC in background job ?
Thanks
Piotr
Use the search to find it is not possible.
Nobody here would know anything about that. I don't think that question has ever been asked before
Use Dataset to transfer data ...
or u can use rfc function to solve this problem .,.
Local preparations
Install RFC-SDK
To transfer files between the SAP® System and a PC in background you need the RFC-SDK to be installed on the PC. The RFC-SDK is installed as a component during setup of your SAP-GUI. If the RFC-SDK is already installed on your PC you will find a directory (for SAP-GUI® 6.20: ..\SAP\Frontend\SAPgui\rfcsdk). If you do not have the RFC-SDK installed you will have to run the setup again and add the development tools.
Configure saprfc.ini
The information about possible RFC-Destinations is kept in a file named saprfc.ini. The location of this file is stored in an environment variable called RFC_INI. To set this variable you have to go to the control panel, open the system icon and choose the environment tab. The screen shot on the right shows you an example of how to set it with Windows2000®.
If you are working with Windows98/SE/ME® you have to add SET RFC_INI=C:\programme\SAP\saprfc.ini to you autoexec.bat.
After installing the RFC-SDK you will find a sample saprfc.ini in the directory rfcsdk\text. The information for DEST and PROGID can be defined individually. IF you want the communication to be save you can add SNC-parameters as described in the sample file. The values for GWHOST and GWSERV depend on your installation.
To get the right values start transaction SMGW on your SAP® system and chose the menu-option Goto-Logged on Clients. In the Gateway Monitor you will find an entry with system type LOCAL_R3. The value for GWHOST will be the LU name and the GWSERV is equivalent to TP NAME.
Start RFC-Server
To start the RFC-Server you have to open the DOS prompt and start the program rfcexec with the option –D <Value of DEST>. Unfortunately the program doesn’t run as a service.
If the program returns to DOS-Prompt it will no longer act as an RFC-Server. You can stop the RFC-Server by pressing Ctrl-C. If the RFC-Server is running you can check the connection in your SAP® System in transaction SMGW. After choosing Goto-Logged on Clients from the Menu you will find an entry with your PCs name in LU Name and the ProgID of the saprfc.ini as TP Name.
Setting in R/3
RFC-Destination
To connect to the RFC-Server from within SAP you have to create an RFC-Destination. To do so start transaction SM59
Create a RFC Destination with the connection type T (TCP-IP Connection). The description is obligatory. After you have done these entries press RETURN.
New parameters will appear on the screen. Choose the Activation Type Registration and press RETURN again. The screen will change again and you have to enter the Prog-ID that you specified in the saprfc.ini.
After saving the RFC Destination you can test you connection. If you succeed it will look like this:
Sample-Coding
Here you can see a sample report downloading a table to a PC. Do not use the pattern function for the statement CALL FUNCTION as the function is not implemented in SAP® but in the rfcexec.
REPORT ZSTEST_RFCDOWNLOAD .
* Testapplication for Filetransfer in Background
*** Data declaration
data: dynamic_table type ref to data,
errmsg(120),
it_rawtab(1024) occurs 0.
field-symbols: <table> type any.
*** Selection-Screen
parameters: p_table type dd02l-tabname
obligatory
default 'T000',
p_file type rlgrap-filename
obligatory
default 'C:\temp\download-t000.txt',
p_dest type rfcdes-rfcdest
obligatory
default 'SAMPLE.RFCEXEC'.
*** Let's start work.
start-of-selection.
* create data dynamically
create data dynamic_table type (p_table).
assign dynamic_table->* to <table>.
* Select data into internal table
select * from (p_table) into <table>.
append <table> to it_rawtab.
endselect.
* Call Download-Funktion
call function 'RFC_REMOTE_FILE'
destination p_dest
exporting
file = p_file
write = 'X' "X=write <space>=read
tables
FILEDATA = it_rawtab
exceptions
SYSTEM_FAILURE = 1 message errmsg
COMMUNICATION_FAILURE = 2 message errmsg.
* tell us about result
if sy-subrc eq 0.
write: / 'Download successfully completed'.
else.
write: / 'Download failed, Reason:',
errmsg.
endif.
During testing the rfcexec it has stopped on errors and needed to be restarted manually.
See the discussion
/forums/viewtopic.php?p=94696&highlight=#94696
KRK
Yes it is possible to download data into file in background. I have done it.
You need to use open dataset to download data from your internal table into file on application server. Then using this file, data can be downloaded into file in background. I have downloaded data into excel sheet in background mode. let me know if you need more details.
Danke Prateek ! I got a solution with U'r explanation. ThanQ once again !
_________________
Regards / mfg
Srinu
"Anyone who has never made a mistake has never tried anything new." - Einstein