‎2008 Apr 16 3:40 PM
Hi,
i have problem in open file ,
when i open the file i get lot of space between rows ,
i use convert and i get table with row but when the data is ending (for every row) i have space in rows how can i avoid that?
<REMOVED BY MODERATOR>
TYPE-POOLS:truxs.
types truxs_t_text_data(4096) type c occurs 0.
DATA: da_tab TYPE truxs_t_text_data.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
i_field_seperator = ';'
i_appl_keep = 'X'
TABLES
i_tab_sap_data = it_d
CHANGING
i_tab_converted_data = da_tab
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = file_n
filetype = 'BIN'
append = 'X'
codepage = 'UTF-8'
CHANGING
data_tab = csv_tab
EXCEPTIONS
file_write_error = 1
no_batch = 2
Regards
Edited by: Alvaro Tejada Galindo on Apr 16, 2008 12:39 PM
‎2008 Apr 16 4:32 PM
Hi Ricardo,
We can use the Function module TEXT_CONVERT_XLS_TO_SAP to read the Excel file on presentation server into the internal table. From this internal table you can fill the target internal table. We dont need to use again cl_gui_frontend_services=>gui_download method.
I hope that it helps u .
Regards,
Venkat.O
report zvenkat-upload-xl no standard page heading.
"----------------------------------------------------------------------
"Declarations.
"----------------------------------------------------------------------
"types
types:
begin of t_bank_det,
pernr(8) type c,
bnksa(4) type c,
zlsch(1) type c,
bkplz(10) type c,
bkort(25) type c,
bankn(18) type c,
end of t_bank_det.
"work areas
data:
w_bank_det type t_bank_det.
"internal tables
data:
i_bank_det type table of t_bank_det.
"---------------------------------------------------------------------
" selection-screen
"----------------------------------------------------------------------
selection-screen begin of block b1 with frame title text_001.
parameters p_file type localfile.
selection-screen end of block b1.
*---------------------------------------------------------------------
"At selection-screen on value-request for p_file.
*---------------------------------------------------------------------
at selection-screen on value-request for p_file.
perform f4_help.
*---------------------------------------------------------------------
"Start-of-selection.
*---------------------------------------------------------------------
start-of-selection.
perform upload_data.
*---------------------------------------------------------------------
"End-of-selection.
*---------------------------------------------------------------------
end-of-selection.
perform display_data.
*&---------------------------------------------------------------------*
"Form f4_help
*&---------------------------------------------------------------------*
form f4_help .
data:
l_file_name like ibipparms-path .
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_FILE'
importing
file_name = l_file_name.
p_file = l_file_name.
endform. " f4_help
*---------------------------------------------------------------------*
"Form upload_data
*---------------------------------------------------------------------*
form upload_data .
type-pools:truxs.
data:li_tab_raw_data type truxs_t_text_data.
data:l_filename like rlgrap-filename.
l_filename = p_file.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
i_tab_raw_data = li_tab_raw_data
i_filename = l_filename
tables
i_tab_converted_data = i_bank_det
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.
endform. " upload_data
*---------------------------------------------------------------------*
" Form display_data
*---------------------------------------------------------------------*
form display_data .
data: char100 type char100.
loop at i_bank_det into w_bank_det .
if sy-tabix = 1.
write w_bank_det.
write / '------------------------------------------------------------'.
else.
write / w_bank_det.
endif.
endloop.
endform. " display_data
‎2008 Apr 16 4:32 PM
Hi Ricardo,
We can use the Function module TEXT_CONVERT_XLS_TO_SAP to read the Excel file on presentation server into the internal table. From this internal table you can fill the target internal table. We dont need to use again cl_gui_frontend_services=>gui_download method.
I hope that it helps u .
Regards,
Venkat.O
report zvenkat-upload-xl no standard page heading.
"----------------------------------------------------------------------
"Declarations.
"----------------------------------------------------------------------
"types
types:
begin of t_bank_det,
pernr(8) type c,
bnksa(4) type c,
zlsch(1) type c,
bkplz(10) type c,
bkort(25) type c,
bankn(18) type c,
end of t_bank_det.
"work areas
data:
w_bank_det type t_bank_det.
"internal tables
data:
i_bank_det type table of t_bank_det.
"---------------------------------------------------------------------
" selection-screen
"----------------------------------------------------------------------
selection-screen begin of block b1 with frame title text_001.
parameters p_file type localfile.
selection-screen end of block b1.
*---------------------------------------------------------------------
"At selection-screen on value-request for p_file.
*---------------------------------------------------------------------
at selection-screen on value-request for p_file.
perform f4_help.
*---------------------------------------------------------------------
"Start-of-selection.
*---------------------------------------------------------------------
start-of-selection.
perform upload_data.
*---------------------------------------------------------------------
"End-of-selection.
*---------------------------------------------------------------------
end-of-selection.
perform display_data.
*&---------------------------------------------------------------------*
"Form f4_help
*&---------------------------------------------------------------------*
form f4_help .
data:
l_file_name like ibipparms-path .
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_FILE'
importing
file_name = l_file_name.
p_file = l_file_name.
endform. " f4_help
*---------------------------------------------------------------------*
"Form upload_data
*---------------------------------------------------------------------*
form upload_data .
type-pools:truxs.
data:li_tab_raw_data type truxs_t_text_data.
data:l_filename like rlgrap-filename.
l_filename = p_file.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
i_tab_raw_data = li_tab_raw_data
i_filename = l_filename
tables
i_tab_converted_data = i_bank_det
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.
endform. " upload_data
*---------------------------------------------------------------------*
" Form display_data
*---------------------------------------------------------------------*
form display_data .
data: char100 type char100.
loop at i_bank_det into w_bank_det .
if sy-tabix = 1.
write w_bank_det.
write / '------------------------------------------------------------'.
else.
write / w_bank_det.
endif.
endloop.
endform. " display_data
‎2008 Apr 16 4:53 PM
HI it is better to delete the separator(i_field_seperator = ';'
) in the 'SAP_CONVERT_TO_CSV_FORMAT' then it will work fine i think ..
and check the simple code for the gui sownload with finary file..
data: begin of itab occurs 0,
f1 type i,
f2 type i,
end of itab .
itab-f1 = 121.
itab-f2 = 232.
append itab .
itab-f1 = 2121.
itab-f2 = 1232.
append itab .
itab-f1 = 1821.
itab-f2 = 2032.
append itab .
data: file type string .
file = 'C:\Documents and Settings\venkatapp\Desktop\testing.txt'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'BIN'
TABLES
DATA_TAB = itab .
regards,
venkat
‎2008 Apr 16 4:57 PM
hi venkat appikonda ,
what do u mean delete the separator?
Regards