2006 Jan 06 9:41 PM
Hello, can I upload several entries from a txt file to a table? maybe via SE16?
TIA
2006 Jan 06 9:57 PM
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
2006 Jan 06 9:45 PM
Not to a table directly (like using SE16), but you can write a program using simple logic.
2006 Jan 06 9:49 PM
2006 Jan 06 9:54 PM
Hi,
Just upload the file into a internal table & then move the internal table fields to the z-table using modify statement.
2006 Jan 06 9:57 PM
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
2006 Jan 06 10:00 PM
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.
2006 Jan 06 10:03 PM
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