You are on page 1of 2

All about AS400 Data Area | Define | Create | Display |

Change | Delete | Use in CL and RPG


AS/400 Data area has remained an illusive thing for many. In this article we will try to learn all about data-area on
an AS400 system. Here we will learn the definition of a data area first and then we will move on to learn how to
create, display, change a data area. Once all this is complete and we have a little understanding of the data area,
We will learn how to actually use them in our CL program and then in RPG program. Let us begin with the
definition of the data area.

Definition of Data Area:


AS400 Data area is an object which has been allocated some memory (Area may be?). Data area can be
understood to be flat file sort of object with only one record of specific length.

We store those frequently used values (Data) in a data area which are supposed to be accessed and updated by
different programs.

Note:- Data area is not a file.Though it stores data. Handling of data area in programs and through commands is
entirely different than that of a file.

There's specific type of data area which is local to a job. What do we call it?

Local Data Area:


Local data area is a job specific data area. You start a job, AS400 system creates a local data area for the
job.Local data area is accessible only to the different programs of the job only i.e Programs of a specific job can
not access the Local data area of another job. We'll learn how to access a local data area in an RPG Program.

How to create a data area


To create a data area we use the CRTDTAARA Command. We follow the following steps to create a data area on
an AS/400 machine.

Firstly we write CRTDTAARA on the command line and press F4 to see the available options.

The prompt displays the following options

• Name of Data area - Enter the name of the data area. Valid values of this field are same as any other
valid name of AS400 Objects.
• Type of the data area -
o Enter *DEC if you have to store numeric only values. Like employee number etc.
o Enter *CHAR if you have to store either character or mixed (Character and numeric)
values. You can separate the character and numeric values through a data structure in an RPG
program.
o Enter *LGL if you have to store a logical value
• Length of the data area - Specify the maximum possible length of the value of the data area. If you
have to store Employe name (15) and Employee Id (5,0) then you should give the length as 20 (15 + 5
etc.).
• Decimal places - Specify the number of decimal places only if you described the type of the data
area as *DEC otherwise leave this field blank
• Initial Value - Specify the initial value of the data area. You may leave this empty as default.
However, do mind the blanks if you are going to save multiple values (Which is very likely) in the data
area.
How to display the current values of a data area.

To display the current value of the data area we use the command DSPDTAARA. To Display the value of the
dataarea we can follow the following steps.

We write the command DSPDTAARA on the command line and take F4. Now fill the values as
below.

• The name of the data area


• The library of the data area.
• Optional output (Screen = *, Spool = *PRINT) - To display the values on the screen enter '*' (Default).
To genrate a spool file, enter '*PRINT'.
• Optional Output Format (*CHAR or *HEX). - TO display the values of the data area as it is (Readable
format) use *CHAR. *HEX displays the data area in hexadecimal format.
Change AS400 Data-Area

We can change the current value or definition of a data area using the command CHGDTAARA . To change a
data area we write the command CHGDTAARA and take F4.

We can specify the following options.

• The name of the data area


• The library where the data area object is placed.
• Optional Substring starting position (Default is *ALL) - This facility gives us freedom to change
only specific portion of the data area. This facility is helpful when we have stored multiple values(E.g Emp
Name, Emp ID) in the data area and we wish to change only specific value(eg.Only Emp ID).
• Optional Substring length - This is the limit of the changed area. This parameter is required if the
optional starting position is different than the default value (*ALL).
• New Value - Enter the new value of the data area here. The new value should be of the same length
as the total length of the data area (Or the substring). If you need to change complete data area, you
should make sure that new value is the concatenation of individual values in their full length. (E.g if Emp
Name (15) and EMP Id (5,0) are the two values which I intend to store in the data area, I will keep the
new value as 'NEWVALUE 12345' instead of 'NEWVALUE12345'. Why? Can you guess!
Delete a Data Area on AS/400 Machine.
This is the easiest and least complex thing. To delete a data area on an AS/400 machine, use the command
DLTDTAARA. This command takes the two arguments name and library of the data area. Provide these
information and press enter when asked to confirm. That's it!

Alternatively, We can use the WRKOBJ command. Enter the name of the data area and object type and library.
Take option 4 and press enter when asked to confirm. (Actually, Option 4 runs the command DLTDTAARA and
passes the required parameters implicitly.)

Common Usage of Data Area


Data Area is commonly used to
• Store Changing Values like Next available Employee Number, Or Current date in specific format etc.
• Store Status of a program or engine or a file etc.
• Lock Handling on Files
• Add your own specific usage....

You might also like