04-21-2009 8:25 AM
Hi All,
While i download data from an Internal table...i need a character(for suppose *)
in between the fields (as a separator). Can this be achieved using GUI_DOWNLOAD ? if not
what is the other way of doing it other than using CONCATENATE functionality.
Thanks !
04-21-2009 8:31 AM
Hi,
Use this FM
SAP_CONVERT_TO_TEX_FORMAT
Below is the sample code
DATA: lv_file_separator TYPE c.
lv_file_separator = '*'.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = lv_file_separator
TABLES
i_tab_sap_data = tb_output1_file
CHANGING
i_tab_converted_data = tb_converted
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.
Then use GUI_DOWNLOAD and provide the above intrernal table ( tb_converted) in the data_tab parameter under tables section.
Regards,
Manish
04-21-2009 8:31 AM
Hi,
Use this FM
SAP_CONVERT_TO_TEX_FORMAT
Below is the sample code
DATA: lv_file_separator TYPE c.
lv_file_separator = '*'.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = lv_file_separator
TABLES
i_tab_sap_data = tb_output1_file
CHANGING
i_tab_converted_data = tb_converted
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.
Then use GUI_DOWNLOAD and provide the above intrernal table ( tb_converted) in the data_tab parameter under tables section.
Regards,
Manish
04-21-2009 8:36 AM
hi,
In GUI_DOWNLOAD, you have an option called
HAS_FIELDSEPARATOR.
Only Tab separation is possible .
HAS_FIELDSEPARATOR = ' '
This takes only two values 'X' and ' '
you can use 'SAP_CONVERT_TO_TEX_FORMAT'
thanks
06-09-2009 10:06 AM
06-09-2009 10:11 AM
Hello,
Just pass the param. WRITE_FIELD_SEPARATOR = 'X' and your problem will be solved.
BR,
Suhas
06-09-2009 10:14 AM
Hi Suhas
Problem Solved. Now the Excel sheet has the field values in column-wise.
One more question...
is it possible in my Excel sheet to have the field names to be included?
Bobby
06-09-2009 10:21 AM
Hello,
Plz Search in SDN. And please create a new post for your req.
TYA.
Suhas
06-09-2009 10:28 AM
Simply, create an header row to put into your table as first row before using GUI_DOWNLOAD (if you don't have numeric fields).
If you have numeric fields, do the same, but move your table into a similar table with fields declared as char or string and then download the that table.
06-09-2009 11:03 AM
06-09-2009 11:17 AM
HI,
Using the GUI_DOWNLOAD function module itself we can downlaod the internal table data to EXCEL.
Sample code:
CONCATENATE filename '.XLS' INTO lv_filename1.
and pass the filename as lv_filename1 to the GUI_DOWNLOAD, with the field seperator value giving as "X".
If you want the header values also for the excel sheet,
Use like this:
Take the gt_header as :
TYPES:BEGIN OF gty_header,
name(30) TYPE c,
END OF gty_header.
gs_header-name = field name.
APPEND gs_header TO gt_header.
CLEAR gs_header.
append all the field names to the gt_header.
and in the function module pass
the gt_header as
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_filename1
write_field_separator = 'X'
TABLES
data_tab = gt_final
fieldnames = gt_header
EXCEPTIONS
file_write_error = 1
unknown_error = 2.
gt_final has the internal table data,
gt_header has field names.
06-09-2009 11:48 AM
Hi Nags
This sounds good.. but still an issue is there.
There are 219 fields in table.. we cannot append them one by one. Is there any ways for that...?
say, all VBAP table fields I need to have in the Excel sheet along with the records.Possible?
Bobby...