Procedure Body Execution
Initialisation
- Fields which are preset because they can be copied from
predefined records are copied.
- If the access mode is batch, the next record for processing is
fetched (in accordance with setting of firstitem).
- If batch access fails, the procedure body is terminated,
returning ESCAPE, unless the procedure was interactive and new
records could be processed.
- If the access mode is Window, Cleared window or Preview window,
the window is displayed and the user is invited to make a selection
(unless it is a preview window). If there are no records for the
window and new records are not allowed or the user presses
<Escape>, the procedure body is terminated, returning
ESCAPE.
- If a record was selected from a window or fetched with a batch
access or the main record is already fetched and is not new,
related tables are joined, the condition on the record is checked
and locking checks are performed. If these checks fail, execution
of the procedure terminates and returns TERMINATED. If no record
was fetched or if New record was selected from a window, and auto
increment was specified, auto increment is performed.
Display
- If the procedure is of type subdevice output, the appropriate
subdevice is selected.
- The map or form for the procedure is displayed.
- The automatically retrieved record or record selected from the
window is pre displayed, if appropriate.
Run Another Program
If the procedure body is of type Run another program, the
command line is executed. If the procedure body is type Link to C,
the C exit is called.
Field Processing
If the procedure is a menu or an action bar, an option is
selected unless force option is set or the user pressed a short cut
function key in an earlier procedure. If the user presses
<Escape>, the Escape option is selected if there is one,
otherwise the procedure is terminated returning ESCAPE.
The fields are processed in turn, as described under Processing for Each Field . All
database accesses and any other questions and remarks in the
procedure are associated with one of the fields (for instance, if
deletion is enabled the question offering to delete the record is
associated with the field at which the main record became
defined).
The processing sequence may be modified by user input, as
described below.
User Input
The user may press one of the keys which move to another field.
When this happens, the following takes place:
- If the field is before the current field, control goes directly
to it, otherwise the current field and all fields prior to the new
field are executed, but without asking for input. This ensures that
the user does not bypass any mandatory input or validation. If
there is mandatory input or validation, the cursor will move only
as far as the relevant field and execution will proceed from that
point as though he had requested to move to it and not the selected
field
- If the user presses the <Escape> key, the procedure is
terminated and its map is cleared from the screen (unless another
procedure originally drew the map and this procedure would not
normally clear it) returning ESCAPE. If the procedure has a window,
however, pressing <Escape> will return to the window (unless
the procedure does not repeat)
- If a database access fails, processing is returned to the first
input field involved in the particular validation (as though a
cursor key had been pressed). If there is no input for this
validation, procedure body execution ceases, returning
TERMINATED
- If the user chooses to delete the record being processed, field
processing ceases
If confirm updates was selected, after the last field has been
processed the user will be offered the Save/rekey/abandon menu. If
rekey is chosen, processing is returned to the point after the main
record is defined.
Posting/Deleting and Final Processing
If field processing is terminated normally:
- All records specified for updating and which satisfy the
condition to update are posted without any checks beyond those
always imposed by the database manager (checks for locking
violation and contention)
Otherwise if deletion is to take place:
- The record to be deleted from the database (and any children)
are removed, checking that no orphans are left
- Other records that are to be updated are posted without any
checks
If the program does not use the private database and the number
of times an updating procedure body has been executed is greater
than or equal to the commit_frequency, the updates are confirmed
with commit(). If this fails and terminate on commit failure was
specified in the program header, the program terminates. Otherwise,
an error message indicating the reason for failure is produced
unless the program header suppressed update fail messages.
If updates fail, execution of the procedure body returns
TERMINATED.
Print output is flushed and the screen is cleared as
appropriate.