*---------*---------------*-----------------*----------------*---------------* | CODE | FACTOR 1 | FACTOR 2 | RESULT | INDICATORS | | | | | FIELD | | *---------*---------------*-----------------*----------------*---------------* | IN | *LOCK | Data area name | | _ ER _ | *---------*---------------*-----------------*----------------*---------------*
The IN operation retrieves a data area and optionally allows you to specify whether the data area is to be locked from update by another program. For a data area to be retrieved by the IN operation, it must be specified in the result field of an *NAMVAR DEFN statement.
Factor 1 can contain the reserved word *LOCK or can be blank. *LOCK indicates that the data area cannot be updated or locked by another program until (1) an UNLCK (Unlock a Data Area or Release a Record) operation is processed, (2) an OUT (Write a Data Area) operation with no factor 1 entry is processed, or (3) the RPG/400 program implicitly unlocks the data area when the program ends.
Factor 1 must be blank when factor 2 contains the name of the local data area or the Program Initialization Parameters (PIP) data area.
You can specify a *LOCK IN statement for a data area that the program has locked. When factor 1 is blank, the lock status is the same as it was before the data area was retrieved: If it was locked, it remains locked; if unlocked, it remains unlocked.
Factor 2 must be either the name of the data area to be retrieved or the reserved word *NAMVAR. When *NAMVAR is specified, all data areas defined in the program are retrieved. If an error occurs on the retrieval of a data area (for example, a data area can be retrieved but cannot be locked), an error occurs on the IN operation and the RPG/400 exception/error handling routine receives control. If a program exception/error subroutine (*PSSR) is specified, the program status data structure contains information on the data area in error. If a message is issued to the requester, the message identifies the data area in error.
You can specify a resulting indicator in positions 56 and 57 to be set on if an error occurs during the operation. Positions 54-55 and 58-59 must be blank.
For further rules for the IN operation, see Data-Area Operations. See Figure "IN and OUT Operations" for an example of the IN operation.
Figure 33. IN and OUT Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C* TOTAMT, TOTGRS, and TOTNET are defined as data areas. The IN C* operation retrieves all the data areas defined in the program C* and locks them. The program processes calculations, and at C* LR time it writes and unlocks all the data areas. C* The data areas can then be used by other programs. C* C *LOCK IN *NAMVAR C* C ADD AMOUNT TOTAMT C ADD GROSS TOTGRS C ADD NET TOTNET C* CLR OUT *NAMVAR C* C *NAMVAR DEFN TOTAMT 82 C *NAMVAR DEFN TOTGRS 102 C *NAMVAR DEFN TOTNET 102
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.