Using data areas

A data area is an object used to hold data for access by any job running on the system.

A data area can be used whenever you need to store information of limited size, independent of the existence of procedures or files. Typical uses of data areas are:

  • To provide an area (perhaps within each job's QTEMP library) to pass information within a job.
  • To provide a field that is easily and frequently changed to control references within a job, such as:
    • Supplying the next order number to be assigned
    • Supplying the next check number
    • Supplying the next save/restore media volume to be used
  • To provide a constant field for use in several jobs, such as a tax rate or distribution list.
  • To provide limited access to a larger process that requires the data area. A data area can be locked to a single user, thus preventing other users from processing at the same time.

To create a data area other than a local or group data area, use the Create Data Area (CRTDTAARA) command. By doing this, you create a separate object in a specific library, and you can initialize it to a value. To use the value in a CL procedure or program, use a Retrieve Data Area (RTVDTAARA) command to bring the current value into a variable in your procedure or program. If you change this value in your CL procedure or program and want to return the new value to the data area, use the Change Data Area (CHGDTAARA) command.

To display the current value, use the Display Data Area (DSPDTAARA) command. You can delete a data area using the Delete Data Area (DLTDTAARA) command.

You can journal your data areas. This allows you to recover the object to a consistent state, even if the object was in the middle of some change action when the abnormal IPL or crash occurred. Journaling also provides for replication of the data area journal to a remote system (using remote journal for instance). This lets the system reproduce the actions in a similar environment to replicate the application work.