code to take a file as input, read that and insert values on that to database

Here you go :

DEFINE VARIABLE cReadFromFile AS CHARACTER NO-UNDO EXTENT 100.
/*100 = number of fields that are part of the record (1 line = 1 record in the file)*/
/*you can change this if you like*/
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
DEF STREAM sIn.
ASSIGN
cFileName = SESSION:TEMP-DIRECTORY + "testfile.dat".

INPUT STREAM sIn FROM VALUE(cFileName).
REPEAT:
ASSIGN
cReadFromFile = "":u.
IMPORT STREAM sIn DELIMITER "|":u cReadFromFile.
MESSAGE cReadFromFile[1] SKIP
cReadFromFile[2] SKIP
cReadFromFile[3] SKIP
cReadFromFile[4]
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
INPUT STREAM sIn CLOSE.
 
Back
Top