Where allowed to run: Compiled CL program or interpreted REXX (*BPGM *IPGM *BREXX *IREXX) Threadsafe: Conditional |
Parameters Examples Error messages |
The Retrieve Data Area (RTVDTAARA) command is used in a CL program or REXX procedure to retrieve all or part of a specified data area and copy it into a variable. RTVDTAARA does not retrieve any other attributes of the data area. Existence of the data area is not required at the time the CL program is compiled.
If the job is a group job, the data area specified may be the group data area (*GDA). This data area is automatically associated with the group, and it is inaccessible from jobs outside the group. The length of this character data area is 512 bytes. More information about group jobs is in the Work Management information in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
A local data area (*LDA) is a character data area that is 1024 bytes in length, and it is automatically associated with the job. Another job cannot access the local data area.
If the job is a prestart job, the data area specified may be the data area that contains program initialization parameter data (*PDA). This data area is automatically associated with the prestart job and is inaccessible from other jobs. The length of this character data area is 2000 bytes. More information about prestart jobs is in the Work Management information in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
When a data area other than a local data area, group data area, or program initialization parameter data area must be retrieved during the processing of the RTVDTAARA command, the data area is locked during the retrieval operation so that commands in other jobs cannot change or destroy it until the operation is complete. If the data area is shared with other jobs and is updated in steps involving more than one command in a job, the data area should be explicitly allocated to that job until all the steps have been performed. A data area other than a local data area, group data area, or program initialization parameter data area can be explicitly allocated with the Allocate Object (ALCOBJ) command. No allocation is necessary for a local data area, group data area, or program initialization parameter data area.
Restrictions
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
DTAARA | Data area specification | Element list | Required, Positional 1 |
Element 1: Data area |
Single values: *LDA, *GDA, *PDA Other values: Qualified object name |
||
Qualifier 1: Data area | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
Element 2: Substring specifications |
Single values: *ALL Other values: Element list |
||
Element 1: Substring starting position | 1-2000 | ||
Element 2: Substring length | 1-2000 | ||
RTNVAR | CL variable for returned value | Not restricted | Required, Positional 2 |
Top |
Specifies the name of the data area whose value is retrieved.
This is a required parameter.
Element 1: Data area
Single values
Qualifier 1: Data area
Qualifier 2: Library
Element 2: Substring specifications
Single values
Element 1: Substring starting position
Element 2: Substring length
Top |
Specifies the name of the variable that receives the contents of the data area.
No type conversion is performed by the RTVDTAARA command:
If a retrieved character string is shorter than the length of the variable specified by the RTNVAR parameter, the value is padded on the right with blanks. The retrieved string length must be less than or equal to the variable length.
When decimal data areas are retrieved, the decimals are aligned. The value of the integer portion of the data area must fit into the integer portions of the variable. Fractional data is truncated if the fraction contains more digits than the variable.
This is a required parameter.
Top |
Assume data area DA1 has been created by the following command:
CRTDTAARA DTAARA(DA1) TYPE(*CHAR) LEN(3) VALUE(ABC)
and variable &CLVAR1 has been declared as:
DCL VAR(&CLVAR1) TYPE(*CHAR) LEN(5) VALUE(VWXYZ)
Example 1: Retrieving a Character Data Area
RTVDTAARA DTAARA(DA1) RTNVAR(&CLVAR1)
results in:
&CLVAR1 = 'ABC '
Example 2: Retrieving a Subset of a Character Data Area
RTVDTAARA DTAARA(DA1 (2 1)) RTNVAR(&CLVAR1)
results in:
&CLVAR1 = 'B '
Example 3: Retrieving a Decimal Data Area
Assume data area DA2 has been created with the following attributes:
CRTDTAARA DTAARA(DA2) TYPE(*DEC) LEN(5 2) VALUE(12.39)
and variable &CLVAR2 has been declared as:
DCL VAR(&CLVAR2) TYPE(*DEC) LEN(5 1) VALUE(4567.8)
Running this command:
RTVDTAARA DTAARA(DA2) RTNVAR(&CLVAR2)
results in:
&CLVAR2 = 0012.3
Note: Fractional digits are truncated instead of rounded.
Top |
*ESCAPE Messages
Top |