|Navigation: Language Reference > 13 - Built-in Functions >====== PREVIOUS (read previous view record in sequence) ======|
PREVIOUS( entity )
|PREVIOUS||Reads the previous record in sequence.|
|entity||The label of a FILE or VIEW declaration.|
PREVIOUS reads the previous record(s) in sequence from a FILE or VIEW. The SET (or RESET) statement determines the sequence in which records are read. Executing PREVIOUS without a preceding SET, or attempting to read past the beginning of a file posts the “Record Not Available” error.
PREVIOUS reads the previous record in sequence from a data file and places it in the RECORD structure data buffer. The first PREVIOUS following a SET reads the record at the position specified by the SET statement. Subsequent PREVIOUS statements read subsequent records in reverse sequence. The sequence is not affected by any GET, REGET, ADD, PUT, or DELETE.
PREVIOUS reads the previous record(s) in sequence from a VIEW and places the appropriate fields in the VIEW structure component files' data buffer(s). If the VIEW contains JOIN structures, PREVIOUS retrieves the appropriate previous set of related records.
Either the SET statement issued on the VIEW's primary file before the OPEN(view) statement, or the SET(view) statement issued after the OPEN(view) determines the sequence in which records are read. The first PREVIOUS(view) reads the record at the position specified by the SET statement. Subsequent PREVIOUS statements read subsequent records in that sequence. The sequence is not affected by PUT or DELETE statements.
|33||Record Not Available|
|37||File Not Open|
|43||Record Is Already Held|
JOIN(Dtl:OrderKey,Hea:OrderNumber) !Join Detail file
JOIN(Pro:ItemKey,Dtl:Item) !Join Product file
LOOP !Read all records through beginning of primary file
PREVIOUS(ViewOrder) !read a record sequentially
IF ERRORCODE() THEN BREAK END !break on end of file
DO PostTrans !call transaction posting routine
END !End loop