09-02-2010 3:32 PM
Hi all!!
I'm downloading a table with this class/method, and when i have worked with a LOCAL folder, it worked fine, but now, i need to put the file into a server folder. So i get the logical path in this way:
10.20.xx.xx
but when i pass the filename to the method: v_filename = '
10.20.xx.xx\file.txt' the file is not generated into this folder.. and i have permission to access and modify this folder..
Thanks for your feedbak!
09-02-2010 3:41 PM
GUI_DOWNLOAD only works for writing to your PC 9or any mapped network drive you can access through your PC). Use DATASETS to write to the server.
09-02-2010 4:00 PM
Hi pampeano, if you want download a file to application server must use OPEN DATA SET statement.
The source code would look something like this:
OPEN DATASET file_path FOR OUTPUT IN TEXT MODE.
IF sy-subrc = 0.
LOOP AT itab.
TRANSFER itab-field TO file_path.
ENDLOOP.
ENDIF.
CLOSE DATASET file_path.
FILE_PATH: File path in the application server.
You can see the file paths by al11 transaction.
09-02-2010 6:23 PM
Hi pampeano, if you want download a file to application server must use OPEN DATA SET statement.
The source code would look something like this:
OPEN DATASET file_path FOR OUTPUT IN TEXT MODE.
IF sy-subrc = 0.
LOOP AT itab.
TRANSFER itab-field TO file_path.
ENDLOOP.
ENDIF.
CLOSE DATASET file_path.
FILE_PATH: File path in the application server.
You can see the file paths by al11 transaction.
Hi Marcel, thanks for your reply!, Some questions..
TRANSFER itab-field TO file_path
if my table have more than one field, i have to add all of them in the transfer sentence? Or what are you referencing with itab-field?
thanks in advance!
09-02-2010 8:55 PM
If you need transfer each record of the table (I suppose itab with header line):
LOOP AT itab.
TRANSFER itab TO file_path
ENDLOOP.
Note: All of fields in itab must be character-type if the file was opened as a text file.
Other example:
OPEN DATASET '/usr/sap/tmp/ztest.txt' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
TRANSFER zdepmentt TO '/usr/sap/tmp/ztest.txt'.
ENDIF.
CLOSE DATASET '/usr/sap/tmp/ztest.txt'.
Here the content of the data object (flat structure) "zdepmentt" is transferred to the application server file '/usr/sap/tmp/ztest.txt'.
Note: The file ztest.txt is automaticaly created.
09-02-2010 10:25 PM
hi again Marcel, now, i tried with:
OPEN DATASET v_file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
IF sy-subrc = 0.
LOOP AT ti_arch2 INTO wa_arch2.
TRANSFER wa_arch2 TO v_file.
endloop.
ENDIF.
CLOSE DATASET v_file.
but the open dataset i get the sy-subrc with " 8 ". Why? Issue about permission? or what?
thanks!
09-02-2010 11:00 PM
Hi,
GUI_DOWNLOAD is used to interact between server and your sap gui. If you need to write into server file system use OPEN DATASET statement.
If you have any write permission issue you need to check with your basis guys the folder permissions.
Regards,
Ivan
09-03-2010 2:59 PM
Hi pampeano.
Replacing the current code for OPEN DATASET statement with the following:
OPEN DATASET v_file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE MESSAGE msg.
Note: A character-type variable can be entered for "msg". The corresponding operating system message is assigned to the data object "msg".
Then test your program and let me know the variable value "msg" . Send me also the variable value "v_file".
09-03-2010 4:54 PM
hi Marcel,
v_file :
server\DATOS\UPLOAD\Sua999999.txt
msg : No such file or directory
this path, entering in AL11 tx, is not there... is it the problem?
if i try hardcoding the v_file variable with "C:\", i can see the file and the content..
thanks in advance!
09-03-2010 8:35 PM
Yes, it's the problem. The directory in "v_file" no exist in your application server.
Through AL11 trx you can see SAP directories.
I want understand this. Do you want transfer data to application server of your SAP System? or
Do you want transfer data to other external server?
09-03-2010 8:47 PM
Hi Marcel,
PROBLEM FIXED!!!!! the issue was the hosts file!!!! I haven't maped there the url for the internal sap server! For this reason i couldn't create the famous file!
THANKS SO MUCH!!