Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

DECLARE-ELEMENT Declare structure element

&pagelevel(4)&pagelevel

Domain: PROCEDURE

Command description

Structure elements can be simple or complex variables (arrays, structures, lists). The following names are therefore used in the operand description below: “simple variable” (if the structure element is a simple variable), “complex variable” (if the structure element itself is a complex variable) and “variable” (if the statement applies to both simple and complex variables).

Variable attributes which cannot be defined in the DECLARE-ELEMENT command are taken from the superordinate structure (e.g. the SCOPE attribute of BEGIN-STRUCTURE or DECLARE-VARIABLE).

If the structure element is a complex variable, its elements must be initialized individually. Complex variables cannot be initialized in their entirety. This command can also be used to declare elements of dynamic structures.

Format

DECLARE-ELEMENT

NAME = list-poss(2000): <composed-name 1..255>(...)

<composed-name 1..255>(...)

INITIAL-VALUE = *NONE / <text 0..1800 with-low expr>

,TYPE = ANY / STRING / INTEGER / BOOLEAN / STRUCTURE(...)

*STRUCTURE(...)

DEFINITION = *DYNAMIC / *BY-SYSCMD / <structured-name 1..20>

,MULTIPLE-ELEMENTS = NO / ARRAY(...) / LIST(...)

ARRAY(...)

LOWER-BOUND = 0 / *NONE / <integer -2147483648..2147483647>

,UPPER-BOUND = *NONE / <integer -2147483648..2147483647>

LIST(...)

LIMIT = *NONE / <integer 1..2147483647>

Operands

NAME = list-poss (2000): <composed-name 1..255>(...)
Declares the variable name.

INITIAL-VALUE = *NONE
The variable is not initialized and is not assigned an initial value.
This means that the contents of an already initialized variable remain unchanged; a new variable does not contain a value, which means that a read access will produce an error.

INITIAL-VALUE = <text 0..1800 with-low expr>
Assigns an initial value to a new simple variable. The value must match the data type of the variable.
The operand can also be specified as an expression.
The entry is ignored for existing simple variables.
Complex variables cannot be initialized in their entirety.
Elements of structure layouts cannot be initialized.

TYPE =
Determines the data type of the variable.

TYPE = *ANY
Any values for the data types STRING, INTEGER and BOOLEAN can be assigned to the variable later on.

TYPE = *STRING
Assigns the data type STRING to the variable.
Value range: any character string.
Length: 0 to 4096 bytes (exception: if the variable is linked to a job variable, it must not be more than 256 bytes long.)

TYPE = *INTEGER
Assigns the data type INTEGER to the variable.
Value range: Integer between -231 and +231-1

TYPE = *BOOLEAN
Assigns the data type BOOLEAN to the variable.
Value range: TRUE, FALSE, ON, OFF, YES, NO

TYPE = *STRUCTURE(...)
Stipulates that the structure element is a complex variable having the type “structure”.

DEFINITION = *DYNAMIC
Dynamically extendable structure.

DEFINITION = *BY-SYSCMD
Static structure whose elements are subsequently declared by commands in the SYSCMD stream.

DEFINITION = <structured-name 1..20>
Name of the structure layout through which the static structure is defined.

MULTIPLE-ELEMENTS = *NO
Determines that the structure elements is not an array or a list.

MULTIPLE-ELEMENTS = *ARRAY(...)
Declares an array, i.e. the structure element is declared as a complex variable having the type “array”.
An array cannot be initialized in its entirety.

LOWER-BOUND = 0 / <integer -2147483648..2147483647>
Lower limit for the array index.

LOWER-BOUND = *NONE
A lower limit is not defined for the array index.

UPPER-BOUND = *NONE
An upper limit is not defined for the array index.

UPPER-BOUND = <integer -2147483648..2147483647>
Upper limit for the array index.

MULTIPLE-ELEMENTS = *LIST(...)
Declares a list, i.e. the structure element is declared as a complex variable having the type “list”.

LIMIT = *NONE
The number of list elements is unlimited.

LIMIT = <integer 1..2147483647>
Defines the maximum number of list elements.

Command return codes

(SC2)

SC1

Maincode

Meaning/Guaranteed messages


0CMD0001No error
10CMD0001Warning; element already declared
20CMD0001Warning; INITIAL-VALUE operand was ignored

1CMD0202Syntax error

1SDP0118Command in false context

3CMD2203Incorrect syntax file

32CMD0221System error (internal error)

64CMD0216Do not have required privilege

64SDP0091

Semantic error

Guaranteed messages: SDP1018


130SDP0099No further address space available

Example 1

/BEGIN-STRUCTURE NAME = BANK-CONNECT(SCOPE = *TASK)
/DECLARE-ELEMENT BANK-CODE(TYPE = *INTEGER)
/DECLARE-ELEMENT ACCT(TYPE = *INTEGER),-
/MULTIPLE-ELEMENTS = *ARRAY(LOWER-BOUND = 1, UPPER-BOUND =3)
/END-STRUCTURE
/DECLARE-VARIABLE PERSON(TYPE = *STRUCTURE(DEFINITION = *BY-SYSCMD))
/BEGIN-STRUCTURE
/DECLARE-ELEMENT SURNAME(TYPE = *STRING)
/DECLARE-ELEMENT FORENAME(TYPE = *STRING)
/DECLARE-ELEMENT BANK-CONNECT(TYPE = *STRUCTURE-
/(DEFINITION = BANK-CONNECT))
/END-STRUCTURE 

Generates the procedure-local structure PERSON:

PERSON.SURNAME
PERSON.FORENAME
PERSON.BANK-CONNECT.BANK-CODE
PERSON.BANK-CONNECT.ACCT

The variables PERSON.SURNAME and PERSON.FORENAME were declared with TYPE = *STRING and can therefore be assigned only strings.
The variable PERSON.BANK-CONNECT.BANK-CODE was declared with
TYPE = *INTEGER and can therefore be assigned only integers.
PERSON.BANK-CONNECT.ACCT is an array containing three elements which can be assigned only INTEGER values. The elements in this array are not yet generated in the variable declaration, but only after the first assignment is made.

For example, the following independent assignments can be made:

PERSON.BANK-CONNECT.BANK-CODE = 70010080

PERSON.BANK-CONNECT.ACCT#1 = 6001023

Example 2

/DECLARE-VARIABLE VARIABLE-NAME = TREE(TYPE = *STRUCTURE(*BY-SYSCMD)),-
/MULTIPLE-ELEMENTS = *ARRAY(LOWER-BOUND = 1,UPPER-BOUND = 
10),/SCOPE = *TASK
/BEGIN-STRUCTURE
/DECLARE-ELEMENT AST,MULTIPLE-ELEMENTS = *ARRAY
/END-STRUCTURE

The following assignments can now be made:

/TREE#1.BRCH#1 =...;  /TREE#1.BRCH#2 =...
/TREE#2.BRCH#1 =...;  /TREE#2.BRCH#2 =...
........
/TREE#10.BRCH#1 =...;  /TREE#10.BRCH#2 =...

Example 3

/BEGIN-STRUCTURE NAME = HOUSING-UNIT
/   DECLARE-ELEMENT NMBR-ROOMS
/   DECLARE-ELEMENT ROOM-SIZE, MULTIPLE-ELEM = *ARRAY
/   DECLARE-ELEMENT TENANT-NAME
/END-STRUCTURE
/DECLARE-VARIABLE BLDG(TYPE = *STRUCTURE(*BY-SYS)),/
       MULTIPLE-ELEMENT = *ARRAY
/BEGIN-STRUCTURE
/DECLARE-ELEMENT APT(TYPE = *STRUCTURE(DEF = HOUSING-UNIT)),/
       MULTIPLE-ELEMENT = *ARRAY
/DECLARE-ELEMENT OWNER(TYPE = *STRUCTURE(DEF = HOUSING-UNIT)),/
       MULTIPLE-ELEMENT = *ARRAY
/DECLARE-ELEMENT ADDRESS(TYPE = *STRUCTURE(DEF = HOUSING-UNIT)),/
       MULTIPLE-ELEMENT = *ARRAY
/END-STRUCTURE

In assignments, the variables are addressed as follows:

BLDG#1.APT#1.NMBR-ROOMS =
BLDG#1.APT#2.NMBR-ROOMS =
BLDG#1.APT#3.NMBR-ROOMS =
...
BLDG#5.APT#8.NMBR-ROOMS =
...

Example 4

The declaration of a structure layout begins with the BEGIN-STRUCTURE command and ends with the END-STRUCTURE command.

/BEGIN-STRUCTURE NAME = AA
/DECLARE-ELEMENT Z
/END-STRUCTURE
/BEGIN-STRUCTURE NAME = BB
/DECLARE-ELEMENT X
/DECLARE-ELEMENT Y
/END-STRUCTURE
/DECLARE-VARIABLE V
/DECLARE-VARIABLE W
/...
/IF (V = W)
/DECLARE-VARIABLE A(TYPE = *STRUCTURE(DEF = AA))
/ELSE
/DECLARE-VARIABLE B(TYPE = *STRUCTURE(DEF = BB))
/END-IF

If V = W applies, structure A is declared (consisting of variables A.Z); otherwise, structure B is declared (consisting of variables B.X, B.Y). Control flow commands and procedure calls containing INCLUDE-PROCEDURE can be placed between BEGIN-STRUCTURE and END-STRUCTURE. However, elements of the calling procedure cannot be declared in the called include procedure. The elements of a structure must be declared in the same procedure as their starting BEGIN-STRUCTURE and ending END-STRUCTURE.
A reference in the include procedure to a structure which has been incompletely declared in this manner will produce an error.

Example 5

/DECLARE-VARIABLE DYN-STRUC(TYPE=*STRUCTURE(DEFINITION=*DYNAMIC))
/DECLARE-ELEMENT DYN-STRUC.SUB.NUMBER(TYPE=*INTEGER)
/DECLARE-ELEMENT DYN-STRUC.LIST,MULTIPLE-ELEMENTS=*LIST
/DYN-STRUC.SUB.STRING='DYNAMICALLY CREATED ELEMENT WITH DATA TYPE *ANY'
/DYN-STRUC.SUB.NUMBER=1234
/DYN-STRUC.LIST#1=1
/DYN-STRUC.LIST#2=2

Notes

  • When elements are being declared for a structure layout, the operand specification NAME=list-poss(2000): <structured-name 1..20>(...) defines only the name of the element, it does not determine the name of the layout.

  • When elements are being declared for a variable which has been defined as a dynamic structure, the operand specification NAME=list-poss(2000):
    <structured-name 1..255>(...) defines the complete name of the element, including the name of the variable as a whole.