Note: Built-In Function Rules Usage Options
Defines a cell (or column) within the nominated space object. Refer also to the other SPACE Built-In Functions.
Arguments
|
Return Values
|
Technical Notes
The specified space object must be defined before any attempt is made to define cells within it (see the CREATE_SPACE Built-In Function)
The currently active invocation stack is searched backwards until the first instance of a field with the specified name is found.
If an instance of the field name is found it is then instantaneously used as a definitional prototype for the space cell in terms of type, length, etc.
If an instance of the field name cannot be found a fatal error message is issued and the application terminates.
It is recommended that all KEY cells be defined as the first cells in a space object.
The order that a key cell is defined implies their order within the aggregate key to the cell row.
The order that any cell is defined implies the order that they will be mapped into and out of other space commands such as INSERT_IN_SPACE and FETCH_IN_SPACE.
If the data in the space requires more than one level of key to uniquely identify an individual entry, then more than one cell MUST be defined as the key.
Examples
Example 1
This example defines a space whose name is the current components name suffixed by ".emp" and then defines 3 cells within it whose type and length are based on the definitions of fields EMPNO, GIVENAME and SURNAME respectively. The first cell the key to the space:
Define #SpaceName *char 20
Use TConcat (*component '.EMP') (#SpaceName)
Use Create_Space (#SpaceName)
Use Define_Space_Cell (#SpaceName EmpNo Key)
Use Define_Space_Cell (#SpaceName GiveName)
Use Define_Space_Cell (#SpaceName SurName);
Example 2
The section file (SECTAB) in the LANSA demonstration system requires that two levels of key be specified to identify any given record. The space must be defined in a similar format. Failure to do so will cause unpredictable results when attempting to retrieve data from the space using SELECT_IN_SPACE and SELECT_NEXT_IN_SPACE.
Define field(#SpaceName) type(*char) length(20)
Use TConcat (*component '.EMP') #SpaceName)
Use Create_Space (#SpaceName)
Use Define_Space_Cell (#SpaceName Deptment Key)
Use Define_Space_Cell (#SpaceName Section Key)
Use Define_Space_Cell (#SpaceName Secdesc)