Previous Topic: Longterm LocksNext Topic: Naming Conventions


Global Records

Global records are records that are available to all dialogs, maps, and user programs in an application. Subschema records cannot be defined as global records.

System-Defined Global Record

The ADSO-APPLICATION-GLOBAL-RECORD is the system-defined global record that enables communication between the application and the runtime system. To be accessed by a dialog, the ADSO-APPLICATION-GLOBAL-RECORD must either be specified as a dialog work record or be associated with the dialog's map. This record is initialized when an application is first loaded by the runtime system.

All fields in the ADSO-APPLICATION-GLOBAL-RECORD are addressable by dialogs or user programs. Selected fields from the ADSO-APPLICATION-GLOBAL-RECORD are listed below. For a complete listing of these fields, refer to the CA ADS Reference Guide.

AGR-NEXT- FUNCTION

The AGR-NEXT-FUNCTION field contains the name of the next function that is to be executed. When the dialog associated with the current function ends with an EXECUTE NEXT FUNCTION command, the function named in the AGR-NEXT-FUNCTION field is executed by the runtime system. A dialog or user program can query this field to check what the next function will be. Modification of the AGR-NEXT-FUNCTION field, however, does not change the next function to be executed; a change in the next function can only be accomplished by modification of the AGR-CURRENT-RESPONSE field (see below).

AGR-DEFAULT- RESPONSE

The AGR-DEFAULT-RESPONSE field contains the default response value specified on the Function Definition screen when an application is compiled. When a value is specified and the screen includes a data field for a default response, the terminal operator can type in a new value or can space out the value that appears.

AGR-CURRENT- RESPONSE

The AGR-CURRENT-RESPONSE field contains the response specified by the terminal operator. The process code of a dialog or user program can also move values into this field, overwriting the user response. Note that, if AGR-CURRENT-RESPONSE is modified by a dialog, security is not checked for the response moving into the field, even if security is associated with this response.

When EXECUTE NEXT FUNCTION is encountered within process code, the response named in the AGR-CURRENT- RESPONSE field is executed if it is a valid response for the current function. The AGR-CURRENT-RESPONSE field determines the next function in the application thread (that is, it determines the value moved into the AGR-NEXT-FUNCTION field).

Moving a Value into AGR-CURRENT- RESPONSE

The following diagram shows the manner in which the runtime system moves a value into the AGR-CURRENT-RESPONSE field. The value in AGR-CURRENT-RESPONSE depends upon whether the AGR-DEFAULT-RESPONSE field contains a value; whether the terminal operator enters a new value in the response field; or whether there is a response value associated with the control key (other than ENTER) pressed by the terminal operator. The runtime system executes the response named in the AGR-CURRENT-RESPONSE field after determining that it is a valid response for the current function.

AGR-EXIT-DIALOG

The AGR-EXIT-DIALOG field initially contains the name of the exit dialog specified on the Application Definition screen. This field can be used to link to a special routine. For example, one department of a company might want the employee name specified as John Doe, while another department wants the name specified as Doe, John. The same dialog could be used for both departments by linking to an exit dialog (that is, LINK TO AGR-EXIT-DIALOG) containing a name routine.

AGR-PRINT- DESTINATION

The AGR-PRINT-DESTINATION field initially contains the default name of the printer for the application as specified on the ADSA Application Definition screen. Dialogs and user programs can use this print destination with the WRITE PRINTER DESTINATION command.

AGR-USER-ID

The AGR-USER-ID field can be queried by dialogs and user programs.

AGR-PRINT-CLASS

The AGR-PRINT-CLASS field initially contains the default printer class for the application as specified on the ADSA Application Definition screen. The dialog can reference this field with the WRITE PRINTER CLASS command.

AGR-SIGNON- SWITCH

The AGR-SIGNON-SWITCH field can be queried to determine if there has been a valid signon.

AGR-SIGNON- REGMTS

The AGR-SIGNON-REQMTS field indicates whether signon is optional, required, or not used for the signon menu, as specified on the Security screen. This field can be referenced for additional security checking.

AGR-MAP- RESPONSE

The AGR-MAP-RESPONSE field can be used as a response field, in place of the $RESPONSE field, in any user-defined nonmenu map. The dialog can initialize this response field before mapout so that the desired default response appears on the map. For input purposes, the AGR-MAP-RESPONSE field works in the same manner as the $RESPONSE field. For information on the $RESPONSE field, refer to the CA IDMS Mapping Facility Guide.

AGR-MODE

The AGR-MODE field initially contains the value STEP or FAST as specified on the Application Definition screen. Typically, the design of a dialog map includes a field that displays the value of AGR-MODE. The terminal operator can change this field at any time.

The following examples show how the AGR-MODE field can be used, in conjunction with the EXECUTE NEXT FUNCTION command, to implement a STEP/FAST mode for an ADSA application. The logic in the first example assumes that all data field validation is handled by the automatic editing specifications in the dialog's map. The logic in the second example assumes that additional data validation is required in the response process code. In both cases, any data entered by the terminal operator is always processed. Note that the first pass flag field has no significance in FAST mode.

Example 1

This sample process code illustrates the manner in which a dialog can query the AGR-MODE field of the ADSO-APPLICATION-GLOBAL- RECORD to determine what course to follow. If the dialog is in STEP mode, the dialog redisplays the screen with a confirmation message for the terminal operator; if in FAST mode, control is passed immediately to the next function. The initial value of AGR-MODE is supplied by the runtime system; the user can alter the value of AGR-MODE at any time during application execution.

IF ANY OF (EMPLOYEE-NBR, SKILL-CODE, SKILL-LEVEL)
  ARE CHANGED
   DO.
     MOVE 'Y' TO FIRST-PASS-FLAG.
     MOVE EMPLOYEE-NBR TO WK-EMPNBR.
     MOVE SKILL-CODE TO WK-SKLCODE.
     MOVE SKILL-LEVEL TO WK-SKLEVEL.
     LINK TO 'CEMDUEMP'.
   END.
IF AGR-STEP-MODE
   DO.
     IF FIRST-PASS-FLAG='Y'
       DO.
         MOVE 'N' TO FIRST-PASS-FLAG.
         DISPLAY MSG TEXT IS 'EMPLOYEE UPDATED'.
       END.
     MOVE 'Y' TO FIRST-PASS-FLAG.
   END.
EXECUTE NEXT FUNCTION.

Example 2

The sample code shown in the following example shows the use of the AGR-MODE field when data validation needs to be handled by code in the response process. Note that the EXECUTE NEXT FUNCTION command is never encountered while uncorrected validation errors still exist.

IF ANY OF (EMPLOYEE-NBR, SKILL-CODE, SKILL-LEVEL)
  ARE CHANGED
   DO.
     MOVE 'Y' TO FIRST-PASS-FLAG.
     IF EMPLOYEE-NBR GE 2000 AND SKILL-CODE='A'
        DO.
          MOVE 'Y' TO ERROR-FLAG.
          DISPLAY MSG TEXT IS
             'EMPLOYEE NUMBER/SKILL CODE MISMATCH'.
        END.
     MOVE 'N' TO ERROR-FLAG.
     MOVE EMPLOYEE-NBR TO WK-EMPNBR.
     MOVE SKILL-CODE TO WK-SKLCODE.
     MOVE SKILL-LEVEL TO WK-SKLEVEL.
     LINK TO 'CEMDUEMP'.
     CALL EMPDTE25.
   END.
IF ERROR-FLAG='Y'
    DISPLAY MSG TEXT IS
       'EMPLOYEE NUMBER/SKILL CODE MISMATCH'.
CALL EMPDTE25.
!**************************************************
DEFINE EMPDTE25.
!**************************************************
IF AGR-STEP-MODE
   DO.
     IF FIRST-PASS-FLAG='Y'
       DO.
         MOVE 'N' TO FIRST-PASS-FLAG.
         DISPLAY MSG TEXT IS 'EMPLOYEE UPDATED'.
       END.
     MOVE 'Y' TO FIRST-PASS-FLAG.
   END.
EXECUTE NEXT FUNCTION.

The following fields from the ADSO-APPLICATION-GLOBAL- RECORD are often mapped to screens associated with user-defined nonmenu maps:

For an illustration of how these fields can be used on maps, refer to "Designing maps" in Chapter 4.