They are small, fast, and powerful and are often referred to as storing counters to enable communication.
They are…
Data Areas: the unsung heroes of IBM i. Here is their story.
What Are Data Areas in AS400?
A Data Area is a special object in AS400 used to store a small amount of data. It is designed for simple, unstructured information that needs to be quickly accessed by different programs at the same time. While similar to variables in programming, its key advantage is that multiple programs can use it simultaneously, making it an extremely useful tool for sharing data across different jobs. There are two main types of Data Areas: user-defined and system-defined.
User-Defined Data Areas
A Data Area is a permanent place on the AS400 system that stores a small amount of data. It is designed to be simple and flexible, allowing multiple programs to read, write, and share information at the same time. This makes it an extremely useful tool for different jobs to access the same data without needing a full database. It should be noted, however, that retrieving the data area is only possible programmatically.
Commands Used for Data Areas
- CRTDTAARA: Used for creation
- DSPDTAARA: Used for the display
- CHGDTAARA: Used for editing or adding
- RTVDTAARA: Used for retrieving data
- DLTDTAARA: Used for deleting the data
Use-Cases
- Configuration Settings: Store configuration parameters such as system settings, user preferences, or application configuration. User-defined data areas provide a wonderful way to centralise and manage system settings and allow easy access and modifications as needed.
- Inter-Program Communication: Create communication between different programs running on the AS400 system. In user-defined data areas, programs can exchange data, enabling seamless interaction and coordination.
- Temporary Data Storage: User-defined data areas provide efficient storage solutions for transient data that needs to be accessed across multiple program executions.
- Cross-Session Data Sharing: The Data Area lets different programs running at the same time on the AS400 system share information. This feature helps them communicate and stay coordinated in real time.
- Error Loading and Monitoring: User-defined data areas can work as a simple log file. They store essential information such as error messages or system updates, which helps a system administrator find and fix problems.
Limitations
User-defined data areas have several limitations:
- Size: They can only hold up to 16 MB of data, making them unsuitable for applications that need to store substantial amounts of information.
- Access: While you can control who can see the data, you have less control over who can edit it compared to other methods of data storage.
- Concurrency: When multiple programs try to access the same data area at once, it can cause problems. Developers must be careful to use proper locking mechanisms to prevent conflicts and keep the data consistent.
- Performance: The system’s performance can slow down when many programs are trying to read from or write to a data area at the same time.
- Backup: They cannot be backed up or recovered on their own, which makes managing the data and recovering from a loss more complex.
Example:
A command for creating the data area ‘CRTDTAARA.’
Use F4 to enter the data area name and the library name associated with it.
Press F4 on Type and select the type of data area you want to create; in this case, we are using *CHAR.
Enter the length of the data area after hitting the Enter key. We are entering 200 here.
On hitting the enter key, the data area is created as shown in the screenshot below.
The data area can be viewed by entering the command DSPDTAARA and pressing F4.
Enter the Data Area and library name, as shown in the screenshot below, and hit enter.
The blank data area below has a size of 200 as shown in the screenshot below:
Add/change the data in the Data Area, we use the command ‘CHGDATAARA’ and press F4
Enter the details below to update the data area as shown in the screenshot below:
View the changes, enter the command below as shown in the screenshot below:
Program to read and display the data area
The program puts a lock and updates the data area.
System-Defined Data Areas
System-designed data areas are predefined and built-in data storage areas within AS400 systems. They are created and maintained by the system itself. These data areas cannot be created and deleted by the user, but a user can add data, retrieve, and display the data.
Types
There are several types of data areas in AS400, each with a specific purpose.
- Local Data Area (LDA): The Local Data Area (LDA) is a temporary space that holds data for a single job. The data is only available while the job is running and is deleted automatically when it finishes. This ensures the information is kept private to that specific job.
- Group Data Area (GDA): A Group Data Area (GDA) is automatically created when a job becomes a “group job.” Only one GDA can exist per group. It gets deleted automatically when the last job in the group finishes, and you cannot create or delete it yourself. The GDA can only be used by the jobs within its group.
- Program Initialisation Parameter (PIP) Data Area (PDA): The Program Initialisation Parameter (PIP) data area is a way to give a program information when it begins, like a file name or a date, without having to change the program’s code.
You can create, update, and read from these data areas using specific commands. This gives programs flexibility and makes them easier to reuse since their settings can be changed without altering the program itself.
Uses-Cases
System-defined data areas are used for several important tasks:
- System Configuration: They store key settings and default values that affect how the entire system runs.
- Inter-Program Communication: Like user-defined data areas, they help different programs share information and work together smoothly.
- System Monitoring: They can be used to log error codes and messages, helping administrators keep an eye on the system and fix problems.
- Security: They store security information such as user profiles and access permissions to help manage who can access what on the system.
Limitations
System-defined data areas have a few drawbacks:
- Size: They have fixed size limits and cannot be changed. For example, the Local Data Area (LDA) is always 1024 bytes, and the Program Initialisation Parameter (PIP) data area is always 2000 bytes. This makes them unsuitable for storing enormous amounts of data.
- Flexibility: Because they are set up by the AS400 system, they are not very flexible. They do not support complex data structures or advanced features, which limits their use for custom applications.
- Security: While they have some security, they do not offer detailed control over who can access and change the data. This can be a problem if you need to store sensitive information.
- Concurrency: When multiple programs try to access the same data at once, it can cause problems if proper locking is not used. This can lead to issues with data accuracy.
Example
Display the data area, we use the command ‘DSPDTAARA’ and press F4
Look at the LDA (Local Data Area), take *LDA as shown in the screenshot below and press enter.
Below is the Local Data Area of length 1024
Make additions/changes to the Data Area, we need to use the command ‘CHGDATAARA’ and press F4.
Enter the details to make changes in LDA, as shown in the screenshot below.
Now, to see the changes, enter the command below as shown in the screenshot below:
Conclusion
Data areas, whether user-defined or system-defined, are key to effective data management and storage. They are essential for organizing, securing, and improving how data is used. Together, they form the backbone of data management strategies, enabling efficient data use, scalability, and easy maintenance.