General syntax of DEFINE DATA CONTEXT
:
DEFINE DATA |
|||||||||
CONTEXT |
USING |
local-data-area | |||||||
parameter-data-area | |||||||||
context-data-definition | |||||||||
END-DEFINE |
This document covers the following topics:
For an explanation of the symbols used in the syntax diagrams, see Syntax Symbols.
Belongs to Function Group: Natural Remote Procedure Call
The DEFINE DATA CONTEXT
statement is used in conjunction
with the Natural RPC (Remote
Procedure Call). It is used to define variables known as context
variables, which are meant to be available to multiple remote subprograms
within one conversation, without having to explicitly pass the variables as
parameters with the corresponding CALLNAT
statements.
A context variable is referenced by its name, and its content is shared by all Natural objects executed in one conversation that refer to that name. The variable is allocated by the first executed Natural object that contains the definition of the variable and is deallocated when the conversation ends.
A context variable is not shared with subprograms that are called within the conversation. If such a subprogram or one of its callees references a context variable, a separate storage area is allocated for this variable.
Context variables can also be used in a non-conversational
CALLNAT
. In this case, the context variables only exist during a
single invocation of this CALLNAT
. The variable is allocated when
the remote subprogram is started and deallocated when it ends. The content is
shared by all programming objects except subprograms executed by this
non-conversational CALLNAT
.
The optional INIT
clause is evaluated in each executed programming object that contains this
clause (not only in the programming object that allocates the variable). This
is different to the way the INIT
works for global variables.
For further information, see Defining a Conversation Context in the Natural RPC (Remote Procedure Call) documentation.
A context variable must be defined at Level 01. Other levels are only used in a redefinition.
Syntax Element | Description |
---|---|
USING
local-data-area |
LDA Name:
A local data
area (LDA) contains data elements which are to be used in a single
Natural module. You may reference more than one data area; in that case you
have to repeat the reserved words DEFINE DATA CONTEXT USING DATX_L CONTEXT USING DATX_P ... END-DEFINE ; For further information, see Defining Fields in a Separate Data Area in the Programming Guide. |
USING
parameter-data-area |
PDA Name:
A parameter data area contains data elements which are used as parameters in a subprogram, external subroutine or dialog. |
context-data-definition |
Context Data Definition:
Context data can be defined directly within a program or routine. For direct data definition, the syntax shown below applies. |
END-DEFINE |
End of DEFINE DATA Statement:
The Natural reserved word |
Context data can be defined directly within a program or routine. For direct data definition, the following syntax applies:
level | variable-definition | ||
redefinition | |||
handle-definition |
For further information, see Defining Fields within a DEFINE DATA Statement in the Programming Guide.
Syntax Element | Description |
---|---|
level |
Level Number:
An application-independent variable must be defined at Level 01. Other levels are only used in a redefinition. |
variable-definition |
Variable Definition:
A For further information, see Variable Definition. Note: |
redefinition |
Redefinition:
A For further information, see Redefinition. |
handle-definition |
Handle Definition:
A handle identifies a dialog element in code and is stored in handle variables. |
Note:
The fields resulting from the redefinition are not considered a
context variable. These fields are treated as local variables.