Explain the data area concept and its usage in the AS400 applications. Please also mention the different types of data areas available in AS400.
How do we use data areas in RPG and CL programs?
How do we use data areas for sharing data between jobs or programs within the same job?
What are the commands used to create, change, retrieve, and delete data areas in the AS400 system?
Data Area is an object that stores data for access by any task executing on the AS400 system. The data area allows you to store a limited amount of data. Users can restore data area objects to their consistent state by using journal data areas in case of an issue.
The data area is used to store and transfer data across jobs, including fields that are constantly modified, such as the next number, whether it be an order number, a check number, or a user number.
Create a data area object using the command
CRTDTAARA
. Local and group data areas cannot be created using theCRTDTAARA
command. While creating a data area object, we can also initialize it with some default values.CRTDTAARA DTAARA(TESTLIB/DTAARA1)
TYPE(*CHAR)
LEN(2000)
VALUE('INIT')
TEXT('Data area 1')
Once the data area object is created, its type is
*DTAARA
, and the attribute is blank. We can create different types of data areas in the as400 system, such as,Points to remember:
We can use the following commands w.r.t the data area object.
RTVDTAARA DTAARA(TESTLIB/DTAARA1 *ALL)
RTNVAR(&VAR1)
CHGDTAARA DTAARA(TESTLIB/DTAARA1 *ALL)
VALUE('NEXTVALUE')
DSPDTAARA DTAARA(libname/DTAARA1)
to view the value stored in a data area object.DLTDTAARA DTAARA(libname/DTAARA1)
to delete the data area object in a specified library from the IBM I machine.