数据区的定义和示例

Displaying a Data Area

You can display the attributes (name, library, type, length, data area text
description), and the value of a data area. See the CL section of the Programming
category in the iSeries Information Center for a detailed description of the
Display Data Area (DSPDTAARA) command.

The display uses the 24-digit format with leading zeros suppressed.


Changing a Data Area

The Change Data Area (CHGDTAARA) command changes all or part of the value
of a specified data area. It does not change any other attributes of the data area.
The new value can be a constant or a CL variable. If the command is in a CL
procedure, the data area does not need to exist when the program is created.

Retrieving a Data Area

The Retrieve Data Area (RTVDTAARA) command retrieves all or part of a
specified data area and copies it into a CL variable. The data area does not need to
exist at compilation time, and the CL variable need not have the same name as the
data area. Note that this command retrieves, but does not alter, the contents of the
specified data area.

Retrieve Data Area Examples
Example 1

Assume that you are using a data area named ORDINFO to track the status of an
order file. This data area is designed so that:
* Position 1 contains an O (open), a P (processing), or a C (complete).
* Position 2 contains an I (in-stock) or an O (out-of-stock).
* Positions 3 through 5 contain the initials of the order clerk.

You would declare these fields in your procedure as follows:
DCL VAR(&ORDSTAT) TYPE(*CHAR) LEN(1)
DCL VAR(&STOCKC) TYPE(*CHAR) LEN(1)
DCL VAR(&CLERK) TYPE(*CHAR) LEN(3)

To retrieve the order status into &ORDSTAT, you would enter the following:
把数据区的内容复制到一个CL变量中
RTVDTAARA DTAARA(ORDINFO (1 1)) RTNVAR(&ORDSTAT)

修改数据区
CHGDTAARA

生成一个数据区
CRTDTAART

删除一个数据区
DLTDTAARA

显示一个数据区
DSPDTAARA

远程数据区
可用DDM来访问远程数据区,在一个AS400上的应用程序要修改或取得在远程AS400的数据区
只需要作如下的一个操作即可
删除标准数据区,再生成一个与其同名的DDM数据区,
把标准数据区改名
生成DDM数据区
CRTDTAARA DTAARA(LOCALLIB/DDMDTAARA) TYPE(*DDM)
RMTDTAARA(REMOTELIB/RMTDTAARA) RMTLOCNAME(SYSTEMB)
TEXT('DDM data ara to access data area on SYSTEMB')
要在CL程序中使用远程AS400的数据区,用RTVDTAARA命令,规定DDM数据区的名字把当前值
放到程序变量中。如果修改之后,要把它放回远程数据区,用CHGDTAARA命令,在其中规定
一个DDM数据区

原文地址:https://www.cnblogs.com/wildfish/p/1031890.html