2009 Aug 20 8:47 AM
Hi,
I am using GUI_DOWNLOAD FM to download my internal table entries into .xls file. It is downloading the file to my local system. But it is not saving in plain .xls file.
Most of the times, the excel file will be downloaded, converted to tab delimited text file. But I need it as a plain .xls file.
Because my client needs to modify the same file and uses to upload it. But they are unable to modify it. It is throwing error like "the document is not compatable with text(tab delimeter)".
Please help me on this situation...
Regards
Ramesh.
2009 Aug 20 9:46 AM
Hi,
Use the function module
SAP_CONVERT_TO_XLS_FORMAT
Here is a sample code:
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_filename = '<<File-Path>>>
* I_APPL_KEEP = ' '
tables
i_tab_sap_data =<Table-Name>
* CHANGING
* I_TAB_CONVERTED_DATA =
* EXCEPTIONS
* CONVERSION_FAILED = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Hope this solves the issue.
Regards,
Rajani
Hi,
I am using GUI_DOWNLOAD FM to download my internal table entries into .xls file. It is downloading the file to my local system. But it is not saving in plain .xls file.
Most of the times, the excel file will be downloaded, converted to tab delimited text file. But I need it as a plain .xls file.
Because my client needs to modify the same file and uses to upload it. But they are unable to modify it. It is throwing error like "the document is not compatable with text(tab delimeter)".
Please help me on this situation...
Regards
Ramesh.
2009 Aug 20 8:57 AM
HI,
You can use Concatenate statement before using GUI_DOWNLOAD
function module.Kindly check the sample code below:
data: v_path type rlgrap-filename,
v_pathname type string .
*func mod to select path for downloading file
call function 'KD_GET_FILENAME_ON_F4'
exporting
program_name = syst-repid
dynpro_number = syst-dynnr
* FIELD_NAME = ' '
* STATIC = ' '
* MASK = ' '
changing
file_name = v_path
exceptions
mask_too_long = 1
others = 2
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*assigning path value to another var to be passed in gui_download
v_pathname = v_path.
*if user gives the value in path var then only download will be called
if v_pathname is not initial.
*TO CONCATENATE EXTENSION WITH THE FILE PATH NAME
concatenate v_pathname '.xls' into v_pathname.
call function 'GUI_DOWNLOAD'
exporting
* BIN_FILESIZE =
filename = v_pathname
filetype = 'ASC'
append = 'X'
write_field_separator = 'X'
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = 'X'
* 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 = '22'
wk1_n_size = '18'
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = <dyn_table>
* 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.
endif.
clear: v_pathname, v_path.
Hope it helps
Regards
Mansi
2009 Aug 20 9:01 AM
Hello,
You can try using XXL_FULL_API function module. It will download the abap data into xls with full details.
also, you can try one more function module:
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
I_FILENAME =
I_APPL_KEEP = ' '
TABLES
I_TAB_SAP_DATA =
CHANGING
I_TAB_CONVERTED_DATA =
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
Hope this resolves your issue.
Thanks,
Augustin.
2009 Aug 20 9:17 AM
Hi ,
Try using FM
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
this will help u
regards
Prashant
2009 Aug 20 9:46 AM
Hi,
Use the function module
SAP_CONVERT_TO_XLS_FORMAT
Here is a sample code:
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_filename = '<<File-Path>>>
* I_APPL_KEEP = ' '
tables
i_tab_sap_data =<Table-Name>
* CHANGING
* I_TAB_CONVERTED_DATA =
* EXCEPTIONS
* CONVERSION_FAILED = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Hope this solves the issue.
Regards,
Rajani
2009 Aug 20 11:24 AM
Thanks to All...
The FM is working fine but it is not writing the COLUMN (HEADING) Names...do needful on this.
Regards,
Ramesh.
2009 Aug 20 11:28 AM
2009 Aug 20 11:32 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |