writeempty

Syntax

WRITEEMPTY (facsname)

Meaning

The WRITEEMPTY instruction creates an empty record in the database table referred to by facsname. The purpose of this is to obtain the future record number of the currently stoerd record, in a before storage ADAPL. Otherwise you would not know the record number until the record was written. Note that when you use this function in a storage adapl, it will be skipped when you import records using the Collections import Test run option because a writeempty is not executed during a test run. If you also mark the Save after successful test checkbox, this function will still be executed though when the virtually imported records are actually saved.
This function can also be used in import adapls. Do make sure that you only write an empty record if you are certain the empty record will also be filled by the adapl with any mandatory values, because otherwise the adapl will have created a completely empty record in your database. However, if the WRITEEMPTY is followed by a SELECT NO (not necessarily directly on the following line) then the current record won't be saved and no empty record will remain either.
The implicit lock will be removed by WRITEEMPTY automatically.

Example

if (val (%0) = 0) {
 /* only if new record
 writeempty (_LOCAL)
}

Result

The record is stored and %0, the record number tag, is filled. This is only relevant in the case of a new record, i.e. if the record number is still ‘0’.

NB: _LOCAL is a special FACS name for general use. _LOCAL points simply to the currently opened database table. So for reading and writing of records it’s not necessary to hard code the FACS name of the database table.

See also

Click here for general information about FACS.