How to check if a read command was executed successfully

The fstat variable contains the result of an operation. Read instruction is the main table reading instruction in Sage ERP X3 code.

When a Read instruction is executed, the cursor state is returned using variable fstat:

- fstat = 0: The record has been successfully read.

- fstat = 5: No record corresponds to the specified criteria (Record not found).

- fstat = 2: For Read instructions with >= and <= clauses: Indicates that a record was found, but that the key value is greater than the specified criteria.

- fstat = 4: For Read Prev / Next, indicates that the end of the table has been reached. For Read First / Last, indicates that the table is empty.

- When the Read instruction is successful, the [F] class is loaded with the field values.