Scott,
In fact, the RPG manual isn't quite correct...
From the "Data Area Operations" section at
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/books_web/c092508502.htm(
*my italics*):
"A data structure defined with a U in position
23<
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/topic/books_web/c0925085332.htm#HDRD23>of
the definition specifications indicates that the data structure is a
data
area. You may specify the DTAARA keyword for a data area data structure, if
specified you can use the IN, OUT and UNLOCK operation codes to specify
further operations for the data area. *The data area is automatically read
and locked at program initialization time, and the contents of the data
structure are written to the data area when the program ends with LR on*. If
the data area for a data area data structure is not found, it will be
created with an initial value of blanks. If the library list was searched
for the data area, the new data area will be created in QTEMP."
If you have the following definition in both caller and called:
D ExtraParm UDS 32 Dtaara(EXTRAPARM)
then the data area is created in QTEMP (if it doesn't exist) read and locked
with *EXCLRD in the caller. In the called program, it's read, but it's
already locked. However, when the called program ends, the lock is released!
So when control returns to the caller, the lock is gone...
To me this seems like a bug - surely the program which initially read it and
obtained the lock (the caller) should keep the lock until *it's* ended?
Rory
p.s. My code:
CALLER:
D ExtraParm UDS 32 Dtaara(EXTRAPARM)
/free
ExtraParm = *all'abc';
out(e) ExtraParm;
callp test2();
dsply ExtraParm;
return;
/end-free
CALLED:
D ExtraParm UDS 32 Dtaara(EXTRAPARM)
/free
dsply ExtraParm;
ExtraParm = *all'def';
out(e) ExtraParm;
return;
/end-free
As an Amazon Associate we earn from qualifying purchases.