Natural provides locking mechanisms that prevent concurrent updating of Natural source objects. These mechanisms allow the locking of source objects that are edited in a local mainframe environment and/or in a SPoD (Natural Single Point of Development) environment connected to a mainframe server.
You can activate or deactivate different object locking mechanisms by
using the profile parameter SLOCK
(see also the
Parameter Reference):
Locking in Local and SPoD EnvironmentsSLOCK=PRE
activates locking of source objects
that are edited either locally or in a SPoD environment, or using Natural ISPF,
or in mixed environments.
SLOCK=PRE
is the recommended setting when
working in mixed environments.
Locking in SPoD Environments
The default setting SLOCK=SPOD
activates object
locking only in a SPoD environment. A source object is then only locked when it
is edited using Natural Studio. For further information, see Object Locking in
the section Remote Development using SPoD in the Natural for Windows
documentation.
In a SPoD environment, SLOCK=SPOD
provides
compatibility with Natural Version 4.1 (and below) and SPoD Version 2.1 (and
below).
Checking for Latest Modification
When setting SLOCK=POST
, the source object which
is being edited can be read into the source work area and modified by multiple
users. However, only the user who saves a modification first can update the
source object. This is done by comparing the time stamp of the source object
stored in the database with the time stamp of the source object when it is read
into the source work area. All other users receive appropriate error messages
when trying to save the source. This is not compatible with the SPoD locking
concept of previous Natural versions.
Locking DeactivatedSLOCK=OFF
deactivates all locking
mechanisms.
The principles of object locking with profile parameter
SLOCK=PRE
set in a local environment are described in
the following sections.
The sources of the following types of Natural object are locked while they are being edited with the appropriate Natural editor:
Program
Subprogram
Subroutine
Copycode
Helproutine
Text
Map
Local data area
Global data area
Parameter data area
DDM (data definition module)
When you invoke a Natural editor, the source contained in the source work area will be locked. If the source object you want to edit has already been locked by another user (as indicated by an appropriate message), the source can be displayed in the editor but without an object name at the top of the screen. If you modify the source and want to keep the modifications, you have to save the source as a new source object with a new name.
Note:
Reading in a source into the source work area by using the
READ
command does not lock the source
object. A source object is only locked when you invoke the Natural
editor.
You cannot save (SAVE
and
STOW
commands) a source that is being locked by
another user.
A locked source object contained in the source work area is unlocked when you do any of the following:
clear the source work area,
read in the source of another source object into the source work area,
log on to another library,
terminate the Natural session,
leave the Natural editor while the Leave Editor with Unlock option is set in the editor profile (see also General Defaults in Editor Profile in the section General Information). This option determines whether the source contained in the current source work area is unlocked when leaving the editor. This also applies to maps and DDMs.
You can use the UNLOCK
system
command (see the System Commands documentation) to view
locked source objects or unlock them if required.
Object locking is also considered when using the system command
DELETE
or RENAME
, the
Object Handler or the utilities SYSMAIN, SYSTRANS or NATLOAD/NATUNLD.
When you move, delete, rename or replace a source object, the locking state of the object is checked:
When the source object is locked, command execution is rejected.
When the source object is not locked, the command is executed.
The utilities SYSRPC, SYSPARM and SYSERR do not support object locking.