‎2010 Feb 24 7:27 AM
Hi Experts
i use gui_download to data in internal table to excel file . My requirement is i want headers for that Excel sheet ,
Like Bpnumber Bpname City ........ in the excel file .
Regards
Krishna
‎2010 Feb 24 7:32 AM
Hi Krishna,
Try Following Code . It will help u
TYPE-POOLS : truxs.
DATA: BEGIN OF tx_tab OCCURS 0,
matnr LIKE ekpo-matnr,
menge(16) TYPE c,
ebeln(34) TYPE c,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
netpr(13) TYPE c,
yy(4) TYPE c,
mm(2) TYPE c,
dd(2) TYPE c,
stk(6) TYPE c,
END OF tx_tab.
DATA: it_final TYPE truxs_t_text_data.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ','
I_LINE_HEADER = 'X'
TABLES
i_tab_sap_data = tx_tab
CHANGING
i_tab_converted_data = it_final
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = fil_path
TABLES
data_tab = it_final
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.
Edited by: Mukund Kansara on Feb 24, 2010 8:34 AM
Edited by: Mukund Kansara on Feb 24, 2010 8:40 AM
‎2010 Feb 24 7:32 AM
Hi Krishna,
Try Following Code . It will help u
TYPE-POOLS : truxs.
DATA: BEGIN OF tx_tab OCCURS 0,
matnr LIKE ekpo-matnr,
menge(16) TYPE c,
ebeln(34) TYPE c,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
netpr(13) TYPE c,
yy(4) TYPE c,
mm(2) TYPE c,
dd(2) TYPE c,
stk(6) TYPE c,
END OF tx_tab.
DATA: it_final TYPE truxs_t_text_data.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ','
I_LINE_HEADER = 'X'
TABLES
i_tab_sap_data = tx_tab
CHANGING
i_tab_converted_data = it_final
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = fil_path
TABLES
data_tab = it_final
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.
Edited by: Mukund Kansara on Feb 24, 2010 8:34 AM
Edited by: Mukund Kansara on Feb 24, 2010 8:40 AM
‎2010 Feb 24 7:32 AM
hi krishna,
fill the internal table which you want download,first record as headings.
regards,
srinivas
‎2010 Feb 24 7:42 AM
Try this. This will help u
data:begin of excel_heading,
text(20) type c,
end of excel_heading.
data:it_heading like standard table of excel_heading initial size 0.
*--Generate the heading for excel data
excel_heading-text = 'A'.
append excel_heading to it_heading.
excel_heading-text = 'B'.
append excel_heading to it_heading.
excel_heading-text = 'C'.
append excel_heading to it_heading.
excel_heading-text = 'D'.
append excel_heading to it_heading.
call function 'GUI_DOWNLOAD'
exporting
filename = p_pfile
filetype = 'DAT'
write_field_separator = '#'
header = '00'
trunc_trailing_blanks = 'X'
show_transfer_status = 'X'
tables
data_tab = p_it_final[]
fieldnames = it_heading[].
‎2010 Feb 24 7:43 AM