Download Internal Table in CSV format it gets downloaded in single column
Hi All
I am converting Internal Table in CSV format using the FM CONVERT TO CSV FORMAT and then downloading data using GUI_DOWNLOAD FM.
I have given separator as ','.
However when I download the data the file is opened in Excel and first 2 to 3 column are merged in to single column and there was separator shown ';'.
How to overcome this problem.
Amol
hI..,
Check this code..
<b>
It first downloads the data in internal table to a CSV format file..
and then uploads the same data into another internal table and prints it..</b>
analyze this and use accordingly..
tables:
spfli.
field-symbols : <fs>, <fs1>.
data:
w_line(1000),
w_field(20) type c,
wa_spfli type spfli.
data:
begin of fs_spfli,
carrid type spfli-carrid,
connid type spfli-connid,
countryfr type spfli-countryfr,
countryto type spfli-countryto,
fltime type spfli-fltime,
end of fs_spfli.
data :
t_file like standard table
of w_line
initial size 0.
data:
t_spfli like
standard table
of fs_spfli
initial size 0.
data:
t_spfli_up like
standard table
of fs_spfli
initial size 0.
select carrid
connid
countryfr
countryto
fltime
into corresponding fields of table t_spfli
from spfli.
loop at t_spfli into fs_spfli.
do.
assign component sy-index of structure fs_spfli to <fs>.
if sy-subrc ne 0.
exit.
endif.
w_field = <fs>.
condense w_field no-gaps.
if sy-index eq 1.
w_line = w_field.
else.
concatenate w_line ',' w_field into w_line.
endif.
enddo.
append w_line to t_file.
endloop.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = 'D:\file.txt'
filetype = 'ASC'
APPEND = ' '
write_field_separator = ' '
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 = t_FILE
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.
clear t_FILE.
call function 'GUI_UPLOAD'
exporting
filename = 'D:\file.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = t_FILE
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
clear fs_spfli.
*constants :
*C_HTAB value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
loop at t_file into w_line.
do.
if w_line eq space.
exit.
endif.
split w_line at ',' into w_field w_line.
condense w_field no-gaps.
assign component sy-index of structure fs_spfli to <fs>.
<fs> = w_field.
enddo.
append fs_spfli to t_spfli_up.
endloop.
loop at t_spfli_up into fs_spfli.
do.
assign component sy-index of structure fs_spfli to <fs>.
if sy-subrc ne 0.
exit.
endif.
write <fs>.
enddo.
skip.
endloop.
reward if it helps u..
sai ramesh
Similar Messages
-
Download internal table in XML format
Hi experts,
I want to download an internal table into an XML format.
How can I achieve this?
I have used the GUI_DOWNLOAD earlier for XLS purpose, will that work in this case too?
Thanks,
Ajay.Hi Ajay,
You can use the below format
DATA : gs_xml TYPE lvc_t_fccl.
(Fill lt_Table here)
TRY.
CALL TRANSFORMATION id SOURCE root = lt_Table
RESULT XML gs_xml.
CATCH cx_st_error.
ENDTRY.
Then Call GUI_DOWNLOAD, passing gs_XML as data_tab and filetype = BIN
Note : GUI_DOWNLOAD will not work in background.
Hope this solves your problem
Regards,
Seema -
Download int table into csv file with each column in separate column in csv
Hi All,
I want to download the data in internal table to CSV file. but each column in the table should come as separate column in csv format.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = GD_FILE
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
tables
DATA_TAB = I_LINES_NEW
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC NE 0.
WRITE: 'Error ', SY-SUBRC, 'returned from GUI_DOWNLOAD SAP OUTBOUND'.
SKIP.
ENDIF.
with the above values passd , I am getting csv file but all the columns in one column separated by some square symbol.
How to separate them into different columns.
Thanks in advance
rgds,
MadhuriBelow example might help you understand on dowloading CSV file:
TYPE-POOLS: truxs.
DATA: i_t001 TYPE STANDARD TABLE OF t001,
i_data TYPE truxs_t_text_data.
SELECT * FROM t001 INTO TABLE i_t001 UP TO 20 ROWS.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ','
* I_LINE_HEADER =
* I_FILENAME =
* I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = i_t001
CHANGING
i_tab_converted_data = i_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.
DATA: file TYPE string VALUE 'C:\testing.csv'.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = file
CHANGING
data_tab = i_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
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards
Eswar -
How to download internal table data to .xlsx file ?
Hello All,
I am using SAP ECC 6.0. I need to download internal table data to .xlsx file.
I tried GUI_DOWNLOAD, all the data are getting transferred to the .xlsx file, but while opening I am getting the below error.
Excel cannot open the file "download.xlsx" because file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
Though Microsoft office 2007 is installed in my system.
Please help <removed by moderator>.
Edited by: Thomas Zloch on Oct 24, 2011 10:55 AMHi,
Please find the below code to download data into excel file.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i.
Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = ' '
DEFAULT_EXTENSION = 'XLS'
default_file_name = 'accountsdata'
INITIAL_DIRECTORY = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
Check user did not cancel request
CHECK ld_result EQ '0'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ld_fullpath
filetype = 'ASC'
APPEND = 'X'
write_field_separator = 'X'
CONFIRM_OVERWRITE = 'X'
TABLES
data_tab = it_datatab[] "need to declare and populate
EXCEPTIONS
file_open_error = 1
file_write_error = 2
OTHERS = 3.
Thanks and Regards
Chitra -
Convert internal table to excel format
I have used GUI_DOWNLOAD function module to download an internal table to excel format.
Download the excel file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = <tab>
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.
And I am able to successfully download the excel file but the problem occurs when I try to open the file.
System throws the warning "The file you are trying to open, '[filename]', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"
And if I click yes, it correctly displays the excel file.
I want to get rid of this warning. Is there any way I can code so that this warning does not occur. Kindly advise.Hi,
Try Like This
data:begin of it occurs 0,
grp type c,
val type i,
end of it.
data:begin of heading occurs 0,
TEXT(10) type c,
end of heading.
it-grp = 'A'.
it-val = 100.
append it.
it-grp = 'B'.
it-val = 200.
append it.
heading-text = 'GROUP'.
append heading.
heading-text = 'VALUE'.
append heading.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:\text.xls'
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = '#'
SHOW_TRANSFER_STATUS = 'X'
tables
data_tab = it[]
FIELDNAMES = heading[]
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. -
Proxy error when downloading report (IR) in csv format
I'm getting the error below when downloading IR report in csv format. I'm getting that whenever the records is more than 108,000. Is there a limit in records to download? Is there a resolution.
I am using apex 4.1, EXCEL 2010.
Thanks,
PinkySince it is a text file it should have no limits within reason..
See if you can recreate issue on Oracle's hosted site..
Simple test, build a standard report on a table that has 101,000 rows and try downloading and then build a IR report on same table..
Thank you,
Tony Miller
Dallas, TX -
Downloading Excel File in CSV Format
Hi All,
How can I Download a file in .CSV Format?
I am using the below shown code.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:\Documents and Settings\sandeepp3\Desktop\sample.csv'
FILETYPE = 'DAT'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ','
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 = ' '
WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
SHOW_TRANSFER_STATUS = ABAP_TRUE
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = ITAB
FIELDNAMES = HTAB
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.
I am getting the field separator as Tab(SPACE).
Please AdviseHi Anil,
Try this way.
REPORT ztest_notepad.
"Declarations
TYPE-POOLS :truxs.
DATA : it_download TYPE truxs_t_text_data.
DATA: BEGIN OF it_data OCCURS 0,
arbgb TYPE t100-arbgb,
msgnr TYPE t100-msgnr,
text TYPE t100-text,
END OF it_data.
START-OF-SELECTION.
"Select Data
SELECT * FROM t100
INTO CORRESPONDING FIELDS OF TABLE it_data UP TO 200 ROWS WHERE sprsl = sy-langu.
"Convert SAP to CSV format
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
i_field_seperator = ';'
TABLES
i_tab_sap_data = it_data
CHANGING
i_tab_converted_data = it_download
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc = 0.
"Download data using GUI_DOWNLOAD
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\test.txt'
filetype = 'ASC'
TABLES
data_tab = it_download.
ENDIF.
Thanks
venkat.O -
Download internal table to XSLX on SAP application server
I was struggling with this feature for a longtime and finally found some solution and so thought of listing it:
Here is what I did to download an internal table to xslx format (works for xls aso) :
I found this excellent link that allowed me to download an XSLX file on to local directory and then I added a little more to download to app server.
http://abapblog.com/articles/tricks/33-create-xlsx-mhtml-file-from-internal-table-in-background
<
Per this link. once the bin file is prepared, pass it to
CALL FUNCTION 'HR_CA_DOWNLOAD_TO_APPSERVER' EXPORTING filename = p_file filesize = g_size IMPORTING bytes_transfered = len TABLES data_tab = gt_bintab EXCEPTIONS invalid_filesize = 1 no_authority = 2 dataset_open_error = 3 OTHERS = 4.
This works for xslx as well as xlsI guess you want to transfer XML document type ref to IF_IXML_DOCUMENT (which is instantiated with this method and stored in attribute M_DOCUMENT ) to a file on application server. Is that right?
If so please refer below program you should get the idea
DATA: gr_ixml TYPE REF TO if_ixml,
gr_ixml_doc TYPE REF TO if_ixml_document.
gr_ixml = cl_ixml=>create( ).
"here you have the same kind of XML document
"as the one created with method CREATE_WITH_DATA
gr_ixml_doc = gr_ixml->create_document( ).
DATA gr_ixml_element TYPE REF TO if_ixml_element.
CALL METHOD gr_ixml_doc->create_element
EXPORTING
name = 'JOBS'
RECEIVING
rval = gr_ixml_element.
CALL METHOD gr_ixml_doc->append_child
EXPORTING
new_child = gr_ixml_element.
CALL METHOD gr_ixml_element->set_attribute
EXPORTING
name = 'OBJID'
value = '566677890'.
"serialization
DATA g_encoding_type TYPE string.
DATA g_stream_factory TYPE REF TO if_ixml_stream_factory.
DATA gr_encoding TYPE REF TO if_ixml_encoding.
g_stream_factory = gr_ixml->create_stream_factory( ).
gr_encoding = gr_ixml->create_encoding( byte_order = 0
character_set = 'UTF-8' ).
DATA b_xml TYPE xstring.
DATA gr_ostream TYPE REF TO if_ixml_ostream.
gr_ostream = g_stream_factory->create_ostream_xstring( b_xml ).
CALL METHOD gr_ostream->set_encoding
EXPORTING
encoding = gr_encoding.
CALL METHOD gr_ixml_doc->render
EXPORTING
ostream = gr_ostream
recursive = 'X'.
DATA g_resize TYPE i.
g_resize = gr_ostream->get_num_written_raw( ).
data ex_tab type table of x255.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = b_xml
tables
binary_tab = ex_tab.
"now open file on application server
OPEN DATASET dset FOR OUTPUT IN BINARY MODE.
"and transfer ex_tab to dset
Regards
Marcin -
Download internal containt in CSV
Hi all there ,
I want to dowload containt of internal table into csv file format, I have used following code but it is giving error while downloading how should i give the path in wf_file or what could be the solution
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ';'
TABLES
i_tab_sap_data = T_INREC
CHANGING
i_tab_converted_data = T_INREC1.
*IF sy-subrc 0.
*ENDIF.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = wf_file
TABLES
data_tab = T_INREC1.Hi Sagar,
I suggest you to use the following example: (I have just used it here )
PARAMETERS : p_filen TYPE rlgrap-filename.
CONSTANTS: c_envvar TYPE string VALUE 'USERPROFILE',
c_title TYPE string VALUE 'Save File'.
DATA: lit_filetable TYPE filetable,
lwa_file LIKE LINE OF lit_filetable.
DATA: lv_rc TYPE sy-subrc,
gv_dirusr TYPE string.
" --- Try to find My Documents path (WinXP)
cl_gui_frontend_services=>environment_get_variable(
EXPORTING
variable = c_envvar
CHANGING
value = gv_dirusr
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4 ).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CONCATENATE gv_dirusr 'My Documents'
INTO gv_dirusr
SEPARATED BY '\'.
ENDIF. " sy-subrc <> 0.
" --- Open Dialog Window to choose destination path
cl_gui_frontend_services=>file_open_dialog(
EXPORTING
window_title = c_title
default_extension = '*.txt'
file_filter = cl_gui_frontend_services=>filetype_text
initial_directory = gv_dirusr
CHANGING
file_table = lit_filetable
rc = lv_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5 ).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
READ TABLE lit_filetable INTO lwa_file INDEX 1.
MOVE: lwa_file-filename TO p_filen.
ENDIF. " sy-subrc <> 0.
Instead of using function modules, you'll can use ABAP objects to do the job.
The same can be done with GUI_DOWNLOAD function, using class CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD. Check it out on SE24.
Regards,
Eduardo -
Download internal table to excel with header
Hi All,
I have a requirement to download internal table contents to excel with field headings. I tried searching in forums before posting but didn't got much help.
I have used GUI_DOWNLOAD, WS_DOWNLOAD and EXCEL_OLE_STANDARD_DAT.
But unable to download the header in excel..along with data...
EXCEL_OLE_STANDARD_DAT is getting field header in excel but not downloading automatically , need to save manually which is not the requirement.
The data is huge with around 151 columns....I got 2 internal tables.
One for the data and the other with field names.
Many Thanks,
Ravi KHi Ravi,
You need to have 2 different internal tables for achieving the needful. One internal table would be having your data and another would store your table field names i.e., declare a structure of length 100 characters,
TYPES : BEGIN OF GTY_FIELDNAMES,
TITLE(100),
END OF GTY_FIELDNAMES.
DATA: GIT_FIELDNAMES TYPE STANDARD TABLE OF GTY_FIELDNAMES,
GWA_FIELDNAMES TYPE GTY_FIELDNAMES.
DATA : GD_FILENAME TYPE STRING,
GD_PATH TYPE STRING,
GD_FULLPATH TYPE STRING,
GD_RESULT TYPE I.
Now have a subroutine where by you append your headings into the internal table i.e.,GIT_FIELDNAMES
CLEAR GWA_FIELDNAMES.
GWA_FIELDNAMES-TITLE = 'Material Number'.
APPEND GWA_FIELDNAMES TO GIT_FIELDNAMES.
CLEAR GWA_FIELDNAMES.
GWA_FIELDNAMES-TITLE = 'Material Description'.
APPEND GWA_FIELDNAMES TO GIT_FIELDNAMES.
Once you are done with it you can call up the save dialog
* Display save dialog window
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = 'Save File As...'
DEFAULT_EXTENSION = 'XLS'
DEFAULT_FILE_NAME = 'SalesPlan'
INITIAL_DIRECTORY = 'C:\'
CHANGING
FILENAME = GD_FILENAME
PATH = GD_PATH
FULLPATH = GD_FULLPATH
USER_ACTION = GD_RESULT.
* Check user did not cancel request
CHECK GD_RESULT EQ '0'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = GD_FULLPATH
FILETYPE = 'ASC'
* APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
* CONFIRM_OVERWRITE = 'X'
TABLES
DATA_TAB = GIT_FINAL " Internal table having data
FIELDNAMES = GIT_FIELDNAMES " Internal table having headings
EXCEPTIONS
FILE_OPEN_ERROR = 1 "#EC ARGCHECKED
FILE_WRITE_ERROR = 2
OTHERS = 3.
Hope this gets sorted your problem.
Thanks & Regards,
Varun Kumar Sahu -
Hi Experts ,
How can I convert my data in internal table to CSV ? I am in SAP CRM 4.0. In R/3 I saw FM for converting into CSV format which is SAP_CONVERT_TO_CSV_FORMAT but its not available in CRM 4.0. Is there any FM available in CRM 4.0.
Please help.
Many Thanks,
NeerajHello Neeraj,
FM:SAP_CONVERT_TO_CSV_FORMAT is not basis module but belogs to FI-TR. So it is not on CRM. I could't find similar FM on CRM, so you should create your FM refer to FM:SAP_CONVERT_TO_CSV_FORMAT on ERP.
Regards,
Masayuki -
How to download internal table data into xml file?
Hi,
Experts,
I have downloaded internal table data into XLS format using GUI_DOWNLOAD Function module, But i didn't Know how to download internal table data into XML format please post some ideas/inputs on this issue.
Thank you,
Shabeer ahmed.check this
data : gd_repid type sy-repid.
GD_REPID = SY-REPID.
DATA : L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
data : l_element type ref to if_ixml_element,
xml_ns_prefix_sf type string,
xml_ns_uri_sf type string.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'REPAIRDATA'
DATAOBJECT = IT_FINAL_LAST1[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
*Start of code for Header
* namespace
t_mnr = sy-datum+4(2).
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
LANGU = 'E'
MONTH = t_mnr
IMPORTING
T247 = wa_t247
concatenate sy-datum+6(2)
wa_t247-ktx
sy-datum(4) into t_var1.
concatenate sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2) into t_var2.
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
l_element = m_document->get_root_element( ).
xml_ns_prefix_sf = 'TIMESTAMP'.
concatenate t_var1 t_var2 into xml_ns_uri_sf separated by space.
clear : t_var1,
t_var2,
t_mnr,
wa_t247.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'FILECREATOR'.
xml_ns_uri_sf = 'SAP'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMGROUP'.
xml_ns_uri_sf = '1'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMTYPES'.
xml_ns_uri_sf = 'W'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
*End of Code for Header
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.
*Start of Code for File name
concatenate p_file
'\R'
'000_119481'
sy-datum+6(2) sy-datum+4(2) sy-datum+2(2)
sy-uzeit(2) sy-uzeit+2(2) sy-uzeit(2) '.xml' into p_file.
*End of Code for File name
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = p_file
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Download internal table data to Excel in background
Hi all ,
Can anyone tell that how i can download internal table data
into Excel sheet in Backgroud Mode .
I used both fun mod ws and gui download but these are not working in background mod .
Please help issue is urgent .
Answer is rewarded by point .
With Regards ,
Nilesh Jainhi,
you have to use function module 'SAP_CONVERT_TO_XLS_FORMAT'.
DATA:
ITAB1 TYPE TRUXS_T_TEXT_DATA.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ';'
I_LINE_HEADER =
i_filename = filename
I_APPL_KEEP = ' '
tables
i_tab_sap_data = itab
CHANGING
I_TAB_CONVERTED_DATA = itab1
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.
try this one.
reward points if useful,
thanks & regards,
rajee. -
Writing from internal table to xml format
Hi,
I searched all the forum and I have a question on writing the data from internal table in xml format to the file on app.server.
Data: ITAB1 TYPE TABLE OF SPFLI,
L_XML TYPE REF TO CL_XML_DOCUMENT.
SELECT * FROM SPFLI INTO TABLE ITAB1.
CREATE THE XML OBJECT
CREATE OBJECT L_XML.
CONVERT THE DATA TO XML
CALL METHOD L_XML->CREATE_WITH_DATA( DATAOBJECT = ITAB1[] ).
after this how to move the XML data in the object to a file on app.server.
Thanksp_ufile is the path of the application server
p_output is the internal table with data to be moved to app serv.
OPEN DATASET p_ufile FOR OUTPUT IN TEXT MODE.
LOOP AT p_output INTO wa_file.
TRANSFER wa_file TO p_ufile.
CLEAR wa_file.
ENDLOOP.
CLOSE DATASET p_ufile.
for XML I guees the path p_ufile ill be <b>sap/usr/tmp/file.xml</b> -
How to disply internal table with grid format .
HI ,
how to disply internal table with grid format .
Regards
venkatGrid format can be disaplyed using two ways,
1. Using reuse_alv_grid_display
2. using object oriented ABAP with the methos set_table_for_first_display.
For example program search in where used list for standard SAP programs.
If this is not the answer then please explain your issue in detail
Thanks,
Rama Krishna
Maybe you are looking for
-
Error while connecting to the AirPort Disk on Windows
good morning to everyone. i am sure this question has been done several times, but i am italian and don't know the correct translation of the message i receive when i try to connect to my airport and so i cannot find the post concerning. i have a 500
-
Itunes 10.7 will not install
I'm running 64-bit Vista Ultimate and the latest Itunes update has failed to install multiple times. My son's laptop running 64-bit 7 Home Premium and it took multiple times for the update to complete successfully. I have chosen the Download Only o
-
Where are BLOB Files stored when using redo log files.
I am using Archive Log Mode for my backups. I was wondering if Blob files get stored in the redo log files or if they are archived somewhere else? Rob.
-
Ok, the project panel does not work anymore!!!!
I'm using flash cs5.5 and today I opened my project to start working... just to find out that the project panel does not work. When I click the tab to expand it, flash hangs for a minute and then it works, but the panel is blank, empty. The odd thing
-
Can't send mail exceeded recipients?
My outbox in Mail is piling up with messages. I keep getting the following message. The server response was: 4.0.0 You have exceeded 400 recipients in the last 24 hours. Try again later. My only options is selecting the mail server are: smtp.mac.com