‎2007 Oct 03 9:00 PM
I have a text file to load txt data into internal table. So how to read text data with validation and to load all text data into the internal table?
Say this is the text file:
IO_NAME, IO_TYPE, IO_SHTXT, IO_LONGTEXT, DATATYPE, DATA LENGTH
ZIO_TEST1, CHA, IO TEST1, IO TEST 1, CHAR, 20
ZIO_TEST2, CHA, IO TEST2, IO TEST 2, CHAR, 20
Regards,
Mau
‎2007 Oct 03 9:22 PM
‎2007 Oct 03 9:22 PM
‎2007 Oct 03 9:30 PM
Hi Clemens,
How would you load millions of text data into internal table?
I want something to read huge text file and to load into internal table if data is good.
Regards,
‎2007 Oct 03 9:41 PM
Hi Mau,
the process for loading 10 lines is the same as for 10 million lines: Read one line, check if it is good regarding your specuial quality criteria. If good, append to internal table. If not, do something else.
If your SAP runs on a notebook, 10 million will need some more storage
Regards,
Clemens
‎2007 Oct 03 9:44 PM
But how to find the directory / location of text file and how to read that file before append?
Regards,
Mau
‎2007 Oct 03 9:50 PM
‎2007 Oct 04 6:45 PM
hi Mau,
look the code I send up...
have the code to find the directory / location of text file like u want.
U can use the FUNCTION <b>'WS_FILENAME_GET'</b>
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = ''
def_path = 'C:\'
mask = ',text documents (*.txt), *.txt.'
mode = ''
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
Regards
Allan Cristian
Message was edited by:
Allan Cristian
‎2007 Oct 04 10:54 PM
‎2007 Oct 03 9:28 PM
hi Mau,
look this code, maybe it's help u.
<b>REPORT ZTXTTOTABLE.</b>
DATA: p_file TYPE string value 'C:\teste.txt',
BEGIN OF TI_table OCCURS 0,
COD(5) TYPE C,
NAME(40),
END OF TI_table,
a(2).
PARAMETERS: sel_file(128) TYPE c
default 'C:\teste.txt' OBLIGATORY LOWER CASE.
p_file = sel_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
TABLES
data_tab = ti_table[].
format color COL_TOTAL INTENSIFIED ON.
loop at ti_table.
write: / sy-vline, ti_table-cod, at 10 sy-vline, ti_table-name,
at 60 sy-vline.
endloop.
write: / sy-uline(60).
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = ''
def_path = 'C:\'
mask = ',Documentos de texto (*.txt), *.txt.'
mode = ''
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
find '.txt' IN p_file.
if sy-subrc <> 0.
concatenate p_file '.txt' into sel_file.
else.
sel_file = p_file.
endif.
top-of-page.
format color COL_HEADING INTENSIFIED ON.
uline (60).
write: / sy-vline, 'COD', at 10 sy-vline, 'NAME', at 60 sy-vline.
write: / sy-uline(60).
good luck!
Regards
Allan Cristian