Application Development and Automation 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: 
Read only

Include entries from file to table

Former Member
0 Likes
1,158

Hello, can I upload several entries from a txt file to a table? maybe via SE16?

TIA

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,113

Sorry, I'm familiar how to save info from an internal table to a table, but not how to upload the info from a file to an internal table, do you have some example?

TIA

Hello, can I upload several entries from a txt file to a table? maybe via SE16?

TIA

6 REPLIES 6
Read only

Former Member
0 Likes
1,113

Not to a table directly (like using SE16), but you can write a program using simple logic.

Read only

Former Member
0 Likes
1,113

Do you have some example?

Read only

0 Likes
1,113

Hi,

Just upload the file into a internal table & then move the internal table fields to the z-table using modify statement.

Read only

Former Member
0 Likes
1,114

Sorry, I'm familiar how to save info from an internal table to a table, but not how to upload the info from a file to an internal table, do you have some example?

TIA

Read only

0 Likes
1,113

DATA: BEGIN OF IT_TABLE OCCURS 0,

FIELD1(10),

FIELD2(10),

END OF IT_TABLE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = 'C:\UPLOAD.TXT'

FILETYPE = 'ASC'

  • HEADLEN = ' '

  • LINE_EXIT = ' '

  • TRUNCLEN = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • DAT_D_FORMAT = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = IT_TABLE

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

NO_AUTHORITY = 10

OTHERS = 11.

MODIFY <dbtab> FROM TABLE IT_TABLE.

*The modify statement will completely transfer the internal table values into the database table at one go.

Read only

0 Likes
1,113

It follows the same principle. You will define an internal table for uploading the file data. That means you need logic for uploading. If you are reading the file from application server, you will use the 'open dataset' syntax, and if you are reading the file from the presentation server, you will use GUI_UPLOAD function module or the OO equivalent of it. Once you upload the file, you will reformat it, validate each record and once everything if ok on the record, you will move it to another internal table having a structure like the database that it is going to update. Once you have your final internal table, use 'Insert dbtab from table itab' construct to insert records into the db table. Read the documentation on insert, modify and update commands using internal tables.

Hope this helps,

Srinivas