2005 Nov 20 9:09 AM
hai..
can anyone tel me how to download data into csv file at presentation layer.
Is gui_upload works ?
Pleae tell me the procedure to do this?
2005 Nov 20 9:33 AM
use GUI_DOWNLOAD to do this.
call function 'GUI_DOWNLOAD'
exporting
* BIN_FILESIZE =
filename = 'c:/ddd/abc.xsl'
<b> filetype = 'DAT'</b>
* APPEND = ' '
<b> WRITE_FIELD_SEPARATOR = ','</b>
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* col_select =
* col_select_mask =
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = <itab iwth data>
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
.Regards
Raja
hai..
can anyone tel me how to download data into csv file at presentation layer.
Is gui_upload works ?
Pleae tell me the procedure to do this?
2005 Nov 20 9:33 AM
use GUI_DOWNLOAD to do this.
call function 'GUI_DOWNLOAD'
exporting
* BIN_FILESIZE =
filename = 'c:/ddd/abc.xsl'
<b> filetype = 'DAT'</b>
* APPEND = ' '
<b> WRITE_FIELD_SEPARATOR = ','</b>
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* col_select =
* col_select_mask =
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = <itab iwth data>
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
.Regards
Raja
2005 Nov 20 11:02 AM
Hi
If you want to create a CSV file you need to create an ASCII file where the fields are separated by semicolon.
So you need a piece of code that inserts the separator (like this):
DATA BEGIN OF RECORD,
FIELD1 LIKE .....,
FIELD2 LIKE .....,
FIELD3 LIKE .....,
.................,
FIELDN LIKE .....,
END OF RECORD.
DATA: T_FILE TYPE STANDARD TABLE OF STRING WITH HEADER LINE.
After filling the structure RECORD with the data to
transfer to file, it appends to file table:
FIELD-SYMBOLS: <FIELD> TYPE ANY.
DATA: OFFSET TYPE I.
CLEAR
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE RECORD TO <FIELD>.
IF SY-SUBRC <> 0. EXIT. ENDIF.
WRITE: <FIELD> TO T_FILE+OFFSET.
OFFSET = STRLEN(T_FILE).
WRITE: ';' TO T_FILE+OFFSET.
OFFSET = OFFSET + 1.
ENDDO.
IF NOT T_FILE IS INITIAL.
APPEND T_FILE.
ENDIF.
call function 'GUI_DOWNLOAD'
exporting
filename = 'c:\ddd\abc.csv'
filetype = 'ASC'
tables
data_tab = T_FILE
......
Max
Hi Raja
On my release (4.70), the FM GUI_DOWNLOAD can use only the types ASC (ASCII) and BIN (binary), not DAT and the parameter WRITE_FIELD_SEPARATOR (it can be SPACE or X)is only to insert the TAB like separator in ASCII file.
So in your release is it different?
Max
2005 Nov 20 11:26 AM
hi Max we are on ECC5.0 (WAS6.4) and you can use DAT there
check out the following line of code taken from the FM
case prc_filetype.
when 'BIN' or 'ASC' or 'DAT' or 'DBF' or 'WK1'.
when 'IBM'.
prc_filetype = 'ASC'.
prc_codepage = '1103'.
when others.
message id 'FES' type 'E' number '004' raising invalid_type.
endcase.and you are right about
parameter WRITE_FIELD_SEPARATOR (it can be SPACE or X). sorry about the mistake,
Regards
Raja
2005 Nov 20 12:16 PM
Thanks Raja
but I believe I'll have to wait for your relase, infact in my relase the code is that:
Filetype parameter valid ?
case prc_filetype.
when 'BIN' or 'ASC' or 'DBF'.
when 'IBM'.
prc_filetype = 'ASC'.
prc_codepage = '1103'.
when others.
message id 'FES' type 'E' number '004' raising invalid_type.
endcase.
I've just forgotten the type DBF and IBM.
Anyway it's good to know on greater release other type of file are managed by that fm.
Thanks
Max
Message was edited by: max bianchi
2005 Nov 21 7:59 AM
2005 Nov 21 8:35 AM