Declare as variable
Component: | SDF-P-BASYS |
Functional area: | Procedures |
Domain: | PROCEDURE |
Privileges: | STD-PROCESSING |
Function
DECLARE-VARIABLE is used to create variables and set the attributes and possibly an initial value as well.
Job variables can be integrated in SDF-P via the CONTAINER operand.
Restrictions
If the chargeable SDF-P subsystem is not available, the following restrictions apply:
Only simple S variables can be declared (TYPE=*ANY and MULTIPLE-ELEMENTS=*NO).
Declarations can only be accepted from a variable container (CONTAINER=<composed-name>). Otherwise, it is only possible to specify CONTAINER=*STD.
The scope can be defined with SCOPE=*CURRENT(...) only. Within the *CURRENT(...) structure, only the default value IMPORT-ALLOWED=*NO is allowed.
Format
DECLARE-VARIABLE | Alias: DCV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Operands
VARIABLE-NAME = list-poss (2000): <structured-name 1..20>(...)
Declares the variable name, i.e. the name of a simple variable which is not an element in a compound variable, or the name of a compound variable.
INITIAL-VALUE = *NONE
The variable is not initialized.
For a new variable, this means that the variable does not contain an initial value. A read access would produce an error.
If the variable is already present, its contents remain unchanged; it is not assigned a new initial value.
INITIAL-VALUE = <text 0..1800 with-low expr >
Assigns an initial value to a new variable; the value must match the data type of the variable and can also be specified as an expression.
The entry is ignored for existing variables; they are not assigned a new initial value. Compound variables cannot be initialized in their entirety, i.e. INITIAL-VALUE cannot be used to assign a new initial value to these variables.
TYPE = *ANY / *STRING / *INTEGER / *BOOLEAN / *STRUCTURE(...)
Assigns the data type to the variable.
TYPE = *ANY
The variable can be assigned any value of data types STRING, INTEGER and BOOLEAN.
MULTIPLE-ELEMENTS = *NO / *ARRAY(...) / *LIST(...)
Specifies whether there can be multiple elements of a variable in an array or a list.
MULTIPLE-ELEMENTS = *NO
Indicates that the variable is not an array or list.
SCOPE = *CURRENT(...) / *PROCEDURE(...) / *TASK(...)
Defines the variable scope.
SCOPE = *CURRENT(...)
The variable is a procedure-local variable.
This corresponds to the PROCEDURE argument in call procedures.
In include procedures, *CURRENT means that the variable is declared in the current include procedure. It is then visible in this include procedure and in all include procedures on lower nesting levels (= scope: include). The lower-level IMPORT-ALLOWED operand is preset to *NO (default value), which means that the declared variable cannot be imported using IMPORT-VARIABLE. If the chargeable SDF-P subsystem is not loaded, only this default value is allowed.
CONTAINER = *STD / <composed-name 1..64> / *VARIABLE(...) / *JV(...)
Defines the assignment of the variable to a container.
CONTAINER = *STD
The variable is not assigned a variable container. The value of the variable is stored in class 5 memory.
CONTAINER = <composed-name 1..64>
Assigns the variable container specified here to the variable declared with this command. Only a previously opened variable container may be specified. The specification of “STD” is not permissible here because “STD” is not interpreted as a permanent variable container.
Return codes
(SC2) | SC1 | Maincode | Meaning/Guaranteed messages |
---|---|---|---|
0 | CMD0001 | No errors | |
1 | 0 | CMD0001 | Warning: Element already declared |
1 | CMD0202 | Syntax error | |
3 | CMD2203 | Incorrect syntax file | |
32 | CMD0221 | System error (internal error) | |
64 | CMD0216 | User does not have required privilege | |
64 | SDP0091 | Semantic error | |
130 | SDP0099 | No more address space available |
Examples
Example 1
The procedure-local variable DATA of type *ANY is initialized with the string 'ANTON' and subsequently, the value of the variable is output with the SHOW-VARIABLE command:
/declare-variable data(c'Anton',*any)
/show-variable data
DATA = Anton
Example 2
The variable container MY-CONT is opened. Then the S variable MY-VAR-1 is declared as a container variable. Once a value has been assigned, the variable container (and thus also the S variable) is saved. When the variable container has been closed, the S variable MY-VAR-1 can no longer be accessed:
/declare-variable my-var-1, container=my-cont
/open-variable-container my-cont,from=*lib-elem(lib=my-lib)
/my-var-1=’saved value’
/show-variable my-var-1
MY-VAR-1 = saved value *END-OF-CMD
/save-variable-container my-cont
/...
/close-variable-container my-cont
/show-variable
% SDP1030 CONTAINER / VARIABLE-CONTAINER 'MY-CONT' DOES NOT EXIST % SDP0234 OPERAND 'NAME' INVALID