2006 Jun 23 4:04 PM
Hi Experts,
I have a large txt file with no fix length of indvidual line. I want it in an internal table of 232 characters each. the structure of table is :-
data: begin of itab occurs 0,
row(232) type c,
end of itab.
pl help me. I tried with gui_upload but it takes only first row.
Regards,
Nirmal
2006 Jun 23 4:10 PM
2006 Jun 23 4:18 PM
Hi
If you are using GUI_UPLOAD
mark the parameter filetype = 'ASC'.
In the text file also check whether there is a line end indicator. If the text file is one continuous line then you may face this problem of only one record being picked up by the function module.
2006 Jun 23 4:23 PM
hi
Make read_by_line import parameter of GUI_UPLOAD as ' '. It is marked 'X' by default.
This will solve the problem even if all the data is in one line.
Hope this solves the issue.
Regards,
Richa
2006 Jun 23 4:44 PM
hi,
have you checked with <b>making read_by_line import parameter of GUI_UPLOAD as ' '</b>. It is marked 'X' by default. This will solve the problem even if all the data is in one line. this should solve your issue
the following code is working fine...
data : lv_file type string.
types : begin of ty_final,
str(10) type c,
end of ty_final.
data : t_res_final type standard table of ty_final.
data : x_res_final type ty_final.
start-of-selection.
lv_file = 'c:abbb.txt'.
call function 'GUI_UPLOAD'
exporting
filename = lv_file
filetype = 'ASC'
<b>read_by_line = ' '</b>
tables
data_tab = t_res_final
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.
write : 'eee'.
endif.
if not t_res_final[] is initial.
loop at t_res_final into x_res_final.
write 😕 x_res_final-str.
endloop.
endif.
Regards,
Richa
2006 Jun 23 4:48 PM
2006 Jun 23 4:24 PM
No the file is not just a single line.
And i used the 'ASC' in FM 'gui_upload'. still there is a problem.
2006 Jun 23 4:27 PM
2006 Jun 23 5:02 PM
could you increase the length of your internal table to char3000 or some large value
and see how much of the row is being populated .
If there is more data than a single line in your file , then your file must be a single line.
2006 Jun 23 4:41 PM
data: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
call function 'GUI_UPLOAD'
exporting
filename = 'c:\file.txt'
filetype = 'ASC'
has_field_separator = 'X'
tables
data_tab = it_datatab
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
.
2006 Jun 23 4:44 PM
hi Nirmal,
Comment this statement i.,e <b>*has_field_separator = 'X'</b> and give a try
2006 Jun 23 4:56 PM
I stil doubt if your file is indeed multiline?
May be your notepad has a word wrap setting which shows the data in multiline but actually it is a single line.
2006 Jun 23 4:59 PM
2006 Jun 23 5:03 PM
Yes Rich,
I think it would be better if we ask him to post the file contents instead of the code..:D..
2006 Jun 23 5:03 PM
2006 Jun 23 5:05 PM
2006 Jun 23 5:07 PM
2006 Jun 23 5:10 PM
hi Nirmal,
Is making <b>read_by_line = ' '</b> not solving the problem? Please let me know if that is the case.
Regards,
Richa
2006 Jun 23 5:12 PM
thanks a lot for your help.
Rich i tried your code but still i displays just one line. I can mail the file as it is a bit confidential.but still it is a plain file generated by a transaction of sap. I used to perform this breaking using Unix's 'fold' command previously.
i wont be reply to your ques now as i have to leave. but would surely appreciate the responses.
thanks
Nirmal
2006 Jun 23 5:14 PM
2006 Jun 23 5:13 PM
Yes richa. read_by_line didnt solved the problem. pl try if it is working.
2006 Jun 23 5:35 PM
hi Nirmal.
if the file is single-line then,
call function 'GUI_UPLOAD'
exporting
filename = lv_file
read_by_line = ' '
tables
data_tab = t_res_final.
if the file is multi-line then,
call function 'GUI_UPLOAD'
exporting
filename = lv_file
tables
data_tab = t_res_final.
These work fine ....
i think if you can provide the file(if not the same file...then some similar file), we will be able to provide some solution.
Regards,
Richa