‎2006 Dec 03 1:03 PM
Hello Experts,
I have issue with '#'. The problem is when I use tab delimited file for upload, system uses '#' as the seperator. System doesn't split at '#' when I use
( split xflat at '#' into table irec ) statement.
start-of-selection.
Add X number of fields to the dynamic itab cataelog
do p_flds times.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'C'.
wa_it_fldcat-inttype = 'C'.
wa_it_fldcat-intlen = 10.
append wa_it_fldcat to it_fldcat .
enddo.
.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
file = p_file.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = file
changing
data_tab = iflat
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.
loop at iflat into xflat.
clear irec. refresh irec.
split xflat at '#' into table irec.
loop at irec.
tabix = sy-tabix.
assign component tabix of structure <dyn_wa> to <dyn_field>.
<dyn_field> = irec.
endloop.
append <dyn_wa> to <dyn_table>.
endloop.
Please help me out. It is very urgent and I have already spent lot of time to solve this issue which couldn't.
Many Thanks.
‎2006 Dec 03 1:12 PM
Hello Sankar
If your SAP release has class <b>CL_ABAP_CHAR_UTILITIES</b> available you might try and use its constant <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB</b> to split your lines instead of using '#'.
Regards
Uwe
‎2006 Dec 03 1:12 PM
Hello Sankar
If your SAP release has class <b>CL_ABAP_CHAR_UTILITIES</b> available you might try and use its constant <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB</b> to split your lines instead of using '#'.
Regards
Uwe
‎2006 Dec 03 1:28 PM
Thanks for the reply.
I have the class CL_ABAP_CHAR_UTILITIES, but method HORIZONTAL_TAB is not available. ..
Oops you mentioned attribute..
Thanks a ton my problem is solved..
Message was edited by:
Sankar Mohan
‎2006 Dec 03 1:56 PM
Hi
Probably Uwe're using a release higher than your.
The HORIZONTAL_TAB is not a method but an attribute of class CL_ABAP_CHAR_UTILITIES, but I think it's defined from rel. 4.7.
Anyway you have to chance:
- First one:
DATA: CHAR_SEP(1) TYPE X VALUE '09'.
LOOP AT IFLAT INTO XFLAT.
.....................
SPLIT XFLAT AT CHAR_SEP INTO TABLE IREC.- The second one: u can use directly the table <dyn_table> and set the paramter TAB_SEPARATOR. In this way the fm split automatically the data.
Message was edited by:
max bianchi
‎2006 Dec 03 3:09 PM
Thanks for the answers..
My problem is solved using CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
‎2006 Dec 03 3:23 PM
‎2006 Dec 03 2:03 PM
Hi,
try using below code
call method cl_gui_frontend_services=>gui_upload
exporting
filename = file
<b>FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'</b>
changing
data_tab = iflat
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.
REgards
Amole