STORE


The STORE statement saves the contents of a field or record in the area assigned as the store area for the field or record. These contents can later be restored into the field or record with the RESTORE statement.

    ••••• STORE    ••• •••••••••••••••••••••• ••• ••••••••••••••
    (1)            (2) (3)                    (4) (5)

(1) T/F execution conditions

(2) Application ID

(3) File name, field name, or predefined field

(4) Occurrence (constant/index)

(5) Data item type (RECORD, FIELD, DEFAULT RECORD, DEFAULT FIELD)

Using the Statement

The STORE statement allows the designer to store the values in a field or record so that temporary use of the field or record for accessing other data records or some other processing does not cause the contents of the field or record to be lost permanently.

The data item type specification can specify FIELD, RECORD, DEFAULT FIELD, or DEFAULT RECORD. If the FIELD or DEFAULT FIELD option is specified, the data item to be saved must be a field in the data dictionary. If the RECORD or DEFAULT RECORD option is specified, the data item to be saved must be specified as a file name. In this case, the current contents of the file’s record area are saved. The occurrence number has no meaning for the STORE statement with the RECORD option.

Fields that are part of a record do not have an independent store or default area. All fields that are part of a record are saved in their proper location in the area assigned for storing the record. Therefore, it is possible to store an entire record and then restore specific fields, or to store only some fields and then restore the entire record. A field or record can be stored any number of times, and it can also be restored any number of times, independently. These statements only cause the contents of the specified field or record to be stored in, or restored from, the store or default area assigned to the field or record. The store area and default area are allocated if a STORE or RESTORE statement is present. They are initialized to the default value; therefore, a RESTORE statement can be executed even if no STORE statement exists for the field or record.

No editing or justification is performed. All data is copied unchanged, and a subsequent RESTORE statement restores the contents of a field or record to the state it was in when the most recent STORE statement was executed.

You can alter the default values of a field or record by using the STORE statement to move current field or record values into the DEFAULT FIELD or DEFAULT RECORD area.

Restrictions

If the FIELD or DEFAULT FIELD option is specified, the data item to be saved must be a field in the data dictionary. If the RECORD or DEFAULT RECORD option is specified, the data item to be saved must be specified as a file name. The occurrence number has no meaning for the STORE statement with the RECORD option.

Because fields that are part of a record do not have a separate store or default area assigned to them, storing a record causes any previously saved contents of fields that are part of that record to be lost. Executing a STORE statement for a field that is part of a record after the record is saved with a STORE statement causes the stored record to be modified.

The contents of predefined fields can also be saved using the STORE statement. Therefore, it is invalid to use the STORE statement for predefined fields that are non-modifiable, since the RESTORE command is invalid for those fields.

Related Statements

RESTORE

Example

In the following example, the amount field RECEIPT2 CHECK AMOUNT is saved, presumably because its contents may be affected during the processing of unpaid invoices. After invoice processing is completed, the field is restored.

          STORE    TAR RECEIPT2 CHECK AMOUNT      FIELD
          SET      TAR WORK COUNT APPLY TO        =      0
          BEG AT   TAR UNPAID   IN TAR RECEIPT2 CUSTOMER NO
          END AT   TAR UNPAID   IN TAR RECEIPT2 CUSTOMER NO
          BEG READ TAR UNPAID                 HOLD 0 KEY IS  UNPAID ALTERNATE KEY
          *        (process unpaid invoices
          END READ TAR UNPAID
          RESTORE  TAR RECEIPT2 CHECK AMOUNT      FIELD