2007 Dec 07 6:02 AM
Hi experts,
is there any function module which will store the result displayed in ALV in excel format directly when the result is displayed....
Regards,
Karthi.
2007 Dec 07 6:06 AM
Hi ,
Use FM 'GUI_DOWNLOAD'.
DATA : l_file TYPE string VALUE 'C:\Documents and Settings\Desktop\mara.xls'.
l_file = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = l_file
filetype = 'ASC'
write_field_separator = ';'
IMPORTING
FILELENGTH =
TABLES
data_tab = i_mara1
FIELDNAMES =
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,
vikas
plz reward if helpful
2007 Dec 07 6:06 AM
Hi ,
Use FM 'GUI_DOWNLOAD'.
DATA : l_file TYPE string VALUE 'C:\Documents and Settings\Desktop\mara.xls'.
l_file = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = l_file
filetype = 'ASC'
write_field_separator = ';'
IMPORTING
FILELENGTH =
TABLES
data_tab = i_mara1
FIELDNAMES =
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,
vikas
plz reward if helpful
2007 Dec 07 6:08 AM
Hi,
Use FM
&----
*& Form sub_download
&----
text
----
--> p1 text
<-- p2 text
----
FORM sub_download.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = p_path
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 = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = it_final
FIELDNAMES =
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.
ENDFORM. " sub_download
Regards,
prashant
2007 Dec 07 6:08 AM
Hi,
YOu can use the GUI_DOWNLOAD function module.
Once you have the data in the internal table, you can either display it as a report or download it to the excel sheet as per the selection in the selection screen.
Regards,
Omkar.
2007 Dec 07 6:09 AM
2007 Dec 07 6:09 AM
Hi,
Try this will download the report to excel
&----
*& Form 1100_DOWNLOAD_FILE "@001
&----
FORM 1110_download_file TABLES xls_tab.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = p_pfile
filetype = 'ASC'
filetype = 'DAT' (for TAB Limited)
IMPORTING
filesize = size filelength = size TABLES
data_tab = xls_tab
EXCEPTIONS
file_open_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = p_pfile
filetype = 'WK1'
IMPORTING
filesize = size
TABLES
data_tab = xls_tab
EXCEPTIONS
file_open_error = 1 * others = 2. invalid_filesize = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
customer_error = 7.
IF sy-subrc NE 0.
WRITE: / 'Download file', p_pfile,
'has error with condition code', sy-subrc.
STOP.
ENDIF.
ENDIF.
ENDFORM. " 1110_DOWNLOAD_FILE
xls_tab this should contain Column headers and the data to be downloaded.
In case of ALV report download
Choose the Export option in the ALV toolbarthen select SPread Sheet then an information mess will appear check that and u will get three option in that choose Tabel option.
Check whether u have passed the values correctly
FORM f9004_display_data TABLES p_output
p_fieldcat.
CALL METHOD o_alvgrid->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = 'A'
is_layout = w_layout
CHANGING
it_outtab = p_output[]
it_fieldcatalog = p_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.