Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Loading Text data into internal table

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi Mau,

see this

If this does not help, enter your sibject in the SEARCH field on top of forum thread list.

Regards,

Clemens

8 REPLIES 8

Clemenss
Active Contributor
0 Kudos

Hi Mau,

see this

If this does not help, enter your sibject in the SEARCH field on top of forum thread list.

Regards,

Clemens

Former Member
0 Kudos

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,

Clemenss
Active Contributor
0 Kudos

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

Former Member
0 Kudos

But how to find the directory / location of text file and how to read that file before append?

Regards,

Mau

Clemenss
Active Contributor
0 Kudos

please search the forum for what you need

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks Allan.

Former Member
0 Kudos

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