Previous Topic: GET QUEUE (DC/UCF)Next Topic: GET STORAGE (DC/UCF)


GET SCRATCH (DC/UCF)

The GET SCRATCH statement obtains a scratch record and places it in a storage area associated with the issuing program. The storage area must already be allocated to the requesting task; no implicit GET STORAGE function is performed during the GET SCRATCH operation. If the scratch record is larger than the designated storage area, data is truncated.

Syntax
►►─── GET SCRATCH ─┬─────────────────────────────┬────────────────────────────►
                   └─ AREA ID (scratch-area-id) ─┘

 ►─┬─────────────────────────────────┬─┬────────────┬─────────────────────────►
   ├─ NEXT ◄ ────────────────────────┤ ├─ DELETE ◄ ─┤
   ├─ FIRST ─────────────────────────┤ └─ KEEP ─────┘
   ├─ LAST ──────────────────────────┤
   ├─ CURRENT ───────────────────────┤
   ├─ PRIOR ─────────────────────────┤
   └─ RECORD ID (scratch-record-id) ─┘

 ►─── INTO (return-scratch-data-location) ────────────────────────────────────►

 ►─┬─ TO (end-scratch-data-location) ───────┬─────────────────────────────────►
   └─ MAX LENGTH (scratch-data-max-length) ─┘

 ►─┬───────────────────────────────────────────────────┬─ ; ──────────────────►◄
   └─ RETURN LENGTH INTO (scratch-data-actual-length) ─┘
Parameters
AREA ID (scratch-area-id)

Identifies the scratch area associated with the record being retrieved. Scratch-area-id is either the symbolic name of a user-defined field that contains the 1- to 8-character scratch area ID or the ID itself enclosed in single quotation marks. If AREA ID is not specified, an area ID of eight blanks is assumed.

NEXT/FIRST/LAST/CURRENT/PRIOR/RECORD ID (scratch-record-id)

Specifies the scratch record to be retrieved:

NEXT

Retrieves the next record in the scratch area. NEXT is the default.

FIRST

Retrieves the first record in the scratch area.

LAST

Retrieves the last record in the scratch area.

CURRENT

Retrieves the current record in the scratch area; the current record is the record most recently referenced by another scratch function.

PRIOR

Retrieves the prior record in the scratch area.

RECORD ID (scratch-record-id)

Retrieves the specified scratch record. Scratch-record-id is the symbolic name of a user-defined FIXED BINARY(31) field that contains the 4-byte scratch record ID.

DELETE/KEEP

Specifies whether the scratch record will be deleted from the scratch area after it is passed to the requesting program:

DELETE

Deletes the record from the scratch area. If DELETE is specified and the record has been truncated, the truncated data is lost. To maintain currency following a DELETE request, the system saves the next and prior currencies of the scratch area. DELETE is the default.

KEEP

Keeps the record in the scratch area.

INTO (return-scratch-data-location)

Specifies the program variable-storage entry of the data area to which the system will return the scratch record. Return-scratch-data-location is the symbolic name of a user-defined field. The length of the data area is determined by one of the following specifications:

TO (end-scratch-data-location)

Indicates the end of the data area to which the system will return the scratch record and is specified following the last data-item entry in return-scratch-data-location. End-scratch-data-location is the symbolic name of either a user-defined dummy byte field or a field that contains a data item not associated with the scratch record.

MAX LENGTH (scratch-data-max-length)

Specifies the length, in bytes, of the data area associated with the requested scratch record. Scratch-data-max-length is either the symbolic name of a program variable-storage field that contains the length, or the length itself expressed as a numeric constant.

RETURN LENGTH INTO (scratch-data-actual-length)

Specifies the symbolic name of the program variable-storage entry to which the system will return the actual length of the requested scratch record. If the record has been truncated, scratch-data-actual-length will contain the length of the full, untruncated scratch record.

Example

The following statement returns the contents of the current record in the scratch area to the variable-storage area defined by WORK_PROC_AREA and END_WORK_PROC_AREA:

GET SCRATCH
  CURRENT
  INTO (WORK_PROC_AREA) TO (END_WORK_PROC_AREA);
Status Codes

Upon completion of the GET SCRATCH function, the ERROR_STATUS field of the IDMS DC communications block indicates the outcome of the operation:

0000

The request has been serviced successfully.

4303

The requested scratch area ID cannot be found.

4305

The requested scratch record ID cannot be found.

4307

An I/O error has occurred during processing.

4319

The program storage area specified for return of the scratch record is too small; the returned record has been truncated to fit the available space.

4331

The parameter list is invalid.

4332

The derived length of the scratch record is negative.