‎2006 Dec 14 5:15 AM
Hi friends.
Can anyone gve me a code to download a file to PC which is been written in unix in text format?
In the program a file is geneated using open dataset. I have to downlaod this file to PC in text format. PLease help......urgent
‎2006 Dec 14 5:17 AM
Hello Abhay,
Read from the file using READ DATASET and populate it into an internal table. Then use function module GUI_DOWNLOAD to download the internal table to the local PC.
Regards,
Manoj
‎2006 Dec 14 5:19 AM
Hi Manoj,
I cannot populate it to internal table... I have to transfer the file to using its file name to PC
‎2006 Dec 14 5:22 AM
If it is one time activity, why don't you use CG3Y transaction.
Regards,
Ravi
‎2006 Dec 14 5:38 AM
Hello Abhay,
Try to use the function module ARCHIVFILE_SERVER_TO_CLIENT and supply PATH as the application server path and TARGETPATH as the path on the PC.
Regards,
Manoj
‎2006 Dec 14 5:22 AM
hi,
u r now downloading to application using DATASET commands. for ur requirement u have to use GUI_DOWNLOAD or WS_DOWNLOAD for download to PC.
however while mentioning file path, u have to be careful as in UNIX we use forward slash '<b>/</b>' and not backward
ex. C:/test.txt
pls. reward if useful...
‎2006 Dec 14 6:19 AM
Hi
Plz try the following code :
data lv_filename type string.
Data : pa_afile LIKE rlgrap-filename,
pa_pfile LIKE rlgrap-filename .
pa_afile = 'filenameonapplication server' .
pa_pfile = 'presentation server file name' .
ra_file = 'X' . " for reading files from application server ,
" leave blank for readign file from presentation server .
" logic for uploading
REFRESH tb_upload. " ur internal table for upload
IF ra_afile = 'X'.
OPEN DATASET pa_afile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
DO.
READ DATASET pa_afile INTO tb_upload.
IF sy-subrc NE 0.
EXIT.
ENDIF.
APPEND tb_upload.
ENDDO.
ENDIF.
CLOSE DATASET pa_afile.
ELSE.
" for uploading from presentation server
lv_filename = pa_pfile.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = tb_upload
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
" now download the data from table to file on PC
pa_pfile = 'name of file on presentation server ie ur PC' .
lv_filename = pa_pfile.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = lv_filename
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = tb_upload
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
this wud upload data from appl server ...and then download to a file on presentation server .
Regards
Pankaj