Enhancing the Function of Exit Form
This section discusses a special re-definition of the default Exit Form functionality. This can be a requirement when the user tries to exit with pending data block changes, and the form should first prompt for saving these changes and then validate the changes if the response to the first prompt is a Yes. This goes in conformity with the dictum, "Validate only if you want to save changes, otherwise exit 'cool-ly'."
The default behavior of KEY-EXIT or EXIT_FORM is to first perform validation and, if successful, prompt for COMMIT, as shown in Figure 8.1. Specifying ASK_COMMIT, NO_COMMIT, DO_COMMIT, or NO_VALIDATE does not achieve our goal.
Figure 8.1. The Save dialog while exiting a form after successful validation.
If validation is a failure, KEY-EXIT or EXIT_FORM throws up another dialog to close the form, as shown in Figure 8.2.
Figure 8.2. The Close dialog while exiting a form after validation failure.
A better way is to prompt for COMMIT and when the user answers Yes to this dialog, validate. Why should it validate when the user doesn't want to commit? This way the functionality of KEY-EXIT or EXIT_FORM is enhanced over the default functionality.
To use this technique, you can re-define KEY-EXIT as follows :
DECLARE
alert_button number;
BEGIN
/* Initially turn off the validation to avpid forms from validating by default */
SET_FORM_PROPERTY(:SYSTEM.CURRENT_FORM, VALIDATION, PROPERTY_FALSE);
ENTER; --- This is required to mark form_success as changed. This will not validate
Категории