| Data area in AS400 |
Data Area
Data Area is an object which is used to hold data for access by any job running on the AS400 system. You can store a limited size of data in the data area.
We can journal data areas which allow us to recover data area objects to their consistent state if any issue occurs.
Use of Data Area
- To provide storage to pass information within a job.
- To provide a field that is frequently changed such as any next number whether its order number or check number or user number etc.
- To provide a constant field to be used by several jobs such as library name or any flag etc.
- To provide limited access to a large process. A data area can be locked by a single user, therefore, preventing others from processing at the same time.
Create Data Area
Use command CRTDTAARA to create a data area other than a local or a group data area. You create a separate object in a library and you can initialize it to a default value.
Create Data Area (CRTDTAARA)
Type choices, press Enter.
Data area . . . . . . . . . . . > DTARA1 Name
Library . . . . . . . . . . . > EASYCLASS1 Name, *CURLIB
Type . . . . . . . . . . . . . . > *CHAR *DEC, *CHAR, *LGL, *DDM
Length:
Length . . . . . . . . . . . . > 2000 1-2000
Decimal positions . . . . . . 0-9
Initial value . . . . . . . . . > TEST
Text 'description' . . . . . . . > 'Test Data Area'
Additional Parameters
Authority . . . . . . . . . . . *LIBCRTAUT Name, *LIBCRTAUT, *CHANGE...
The data area is created successfully.
Data area DTARA1 created in library EASYCLASS1.
WRKOBJ EASYCLASS1/DTARA1
Work with Objects
Type options, press Enter.
2=Edit authority 3=Copy 4=Delete 5=Display authority 7=Rename
8=Display description 13=Change description
Opt Object Type Library Attribute Text
DTARA1 *DTAARA EASYCLASS1 Test Data Area
Retrieve Data Area value in CL program
Use command RTVDTAARA to retrieve data area value in CL program variable.
Retrieve Data Area (RTVDTAARA)
Type choices, press Enter.
Label . . . . . . . . . . . . .
Data area specification: DTAARA
Data area . . . . . . . . . . > DTARA1
Library . . . . . . . . . . > EASYCLASS1
Substring specifications:
Substring starting position . > *ALL
Substring length . . . . . . .
CL variable for returned value RTNVAR > &VALUE
Comment . . . . . . . . . . . .
Retrieve Data Area (RTVDTAARA)
Type choices, press Enter.
Label . . . . . . . . . . . . .
Data area specification: DTAARA
Data area . . . . . . . . . . > DTARA1
Library . . . . . . . . . . > EASYCLASS1
Substring specifications:
Substring starting position . > 5
Substring length . . . . . . . 5
CL variable for returned value RTNVAR > &VALUE
Comment . . . . . . . . . . . .
Change Data area
Use command CHGDTAARA to change the contents of the data area.
Change Data Area (CHGDTAARA)
Type choices, press Enter.
Data area specification: DTAARA
Data area . . . . . . . . . . > DTARA1
Library . . . . . . . . . . > EASYCLASS1
Substring specifications:
Substring starting position . *ALL
Substring length . . . . . . .
New value . . . . . . . . . . . VALUE > 'HELLO'
Change Data Area (CHGDTAARA)
Type choices, press Enter.
Data area specification: DTAARA
Data area . . . . . . . . . . > DTARA1
Library . . . . . . . . . . > EASYCLASS1
Substring specifications:
Substring starting position . > 2
Substring length . . . . . . . > 4
New value . . . . . . . . . . . VALUE > 'CHG1'
Display Data area
Use command DSPDTAARA to display the current value of the data area.
Display Data Area (DSPDTAARA)
Type choices, press Enter.
Data area . . . . . . . . . . . DTAARA > DTARA1
Library . . . . . . . . . . . > EASYCLASS1
Output . . . . . . . . . . . . . OUTPUT *
Output format . . . . . . . . . OUTFMT *CHAR
Additional Parameters
System . . . . . . . . . . . . . SYSTEM *LCL
Press ENTER to display the content of the data area after entering the above DSPDTAARA command.
Display Data Area
System
Data area . . . . . . . : DTARA1
Library . . . . . . . : EASYCLASS1
Type . . . . . . . . . : *CHAR
Length . . . . . . . . : 2000
Text . . . . . . . . . : Test Data Area
Value
Offset *...+....1....+....2....+....3....+....4....+....5
0 'TEST '
50 ' '
100 ' '
150 ' '
200 ' '
250 ' '
300 ' '
350 ' '
400 ' '
Press Enter to continue.
Delete Data area
Use command DLTDTAARA to delete the data area object.
Delete Data Area (DLTDTAARA)
Type choices, press Enter.
Data area . . . . . . . . . . . DTAARA > DTARA1
Library . . . . . . . . . . . > EASYCLASS1
Data area object deleted successfully.
Selection or command
===>
F3=Exit F4=Prompt F9=Retrieve F12=Cancel
F23=Set initial menu
Object DTARA1 in EASYCLASS1 type *DTAARA deleted.
Data Area Locking and Allocation
Remote Data Area
Read about Remote Data Area from the following article
Remote Data Area in AS400Local Data Area
Read about Local Data Area from the following article
Local Data Area in AS400Group Data Area
Read about group Data Area from the following article
Group Data Area in AS400Program Initialization Parameter Data Area
Read about Program Initialization Parameter Data Area from the following article
Program Initialization Parameter Data Area in AS400