2005 Sep 04 11:20 AM
Hello,
I'm trying to read a text file into an internal table of text lines using GUI_UPLOAD. The problem is that I can only read a maximum of 255 characters from each line. So for example, if the first line in the text file contains 260 characters, I lose the last 5 characters of that line.
Any ideas on how to read the ENTIRE contents of a text file into an internal table of text lines? I'd really appreciate any help!
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = 'c:\example.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = SPACE
HEADER_LENGTH = 0
DAT_MODE = SPACE
CODEPAGE = SPACE
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
READ_BY_LINE = 'X'
IMPORTING
FILELENGTH =
HEADER =
CHANGING
data_tab = int_textline
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
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
error handling
ENDIF.
thanks,
Ahmad
2005 Sep 04 11:38 AM
modify your int_textline definition to something like below.
data: begin of int_textline occurs 0,
int_txt(500) type c,
end of int_tab1.
Regards
Raja
2005 Sep 04 11:38 AM
modify your int_textline definition to something like below.
data: begin of int_textline occurs 0,
int_txt(500) type c,
end of int_tab1.
Regards
Raja
2005 Sep 04 11:56 AM
Hi Raja,
As you suggested, I used:
DATA: BEGIN OF fs_textline OCCURS 0,
text(500) TYPE c,
END OF fs_textline.
DATA: int_textline LIKE TABLE OF fs_textline.
But that doesn't solve the problem. If I'm not mistaken, the issue is that you can't store more than 255 char per variable/field.
Best Regards,
Ahmad
2005 Sep 04 12:01 PM
No. you can store more than 255 chars.
if you change the internal table as per the declaration i have given , while uploading you wont miss any characters.
<i><b>the issue is that you can't store more than 255 char per variable/field</b></i>.
No you can store. there is a variable type STRING where you can store large value also you can simply declare a variable like data: abc(3000).
What is the exact problem you are facing?
Regards
Raja
2005 Sep 04 12:12 PM
Hi Ahmad,
The function module can take more that 255 characters. Just follow the declaration Raja suggested. It is working for me.
DATA: BEGIN OF it_datatab OCCURS 0,
row(500) TYPE c,
END OF it_datatab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'c:\test.txt'
filetype = 'ASC'
TABLES
data_tab = it_datatab
EXCEPTIONS
file_open_error = 1
OTHERS = 2.
Thanks
Vinod
2005 Sep 04 12:23 PM
You shouldn't have any problems about the lenght of file line. You can upload files with longer lines than 255 chars.
Perhaps is your problem how writing (read?) a file in abap list?
In this case you have a limit of 255 chars.
2005 Sep 04 12:39 PM
The 255 char output limit was causing my confusion. Thanks to Raja and the rest for helping me out.
Best Regards,
Ahmad
2015 Jan 13 3:24 PM
Hi Raja,
I am also faceing the same EXCEL issue while loading data using BODS. It only fetches 255 characters from excel.
I have your solution for this.
Can you please help me out how to use the above script/Code in BODS with detailed explanation for e.g. declaring variables etc, So that I can Implement the same in my JOB.
Thanks for your support in Advance.
Regards,
Sagar