Bryan's RPG IV Journal
Defining a Data Area Data Structure
Q. What is the best way using D-specs to define a data area, where I want to get the value from the data area and never lock the data area? We use a data area to hold an encryption key. Other programmers are using the old *DTAARA DEFINE, directly followed by an UNLOCK because they say the D-specs can't handle it without locking the data area. Is there a better way?
A. When you use UDS in columns 23-25 to define a data area data structure, the RPG program will read and lock the data area automatically when the program starts, then upate and lock it when the program ends.
You can use the IN, OUT, and UNLOCK operations to specify additional operations, but the data area will be locked when the program begins:
A. When you use UDS in columns 23-25 to define a data area data structure, the RPG program will read and lock the data area automatically when the program starts, then upate and lock it when the program ends.
You can use the IN, OUT, and UNLOCK operations to specify additional operations, but the data area will be locked when the program begins:
D Mydta UDS DTAARA('MYDTAARA')
... (Subfields)
/Free
Unlock Mydta; // Unlock MYDTAARA
/End-freeIf you want to read a data area without locking
it, omit the U from column 23, but use the DTAARA keyword on the definition. Then, explicitly control the data area, using the IN and OUT operations to read and update the data area:D Lda DS DTAARA(*LDA)
... (Subfields)
D Mydta DS DTAARA('MYDTAARA')
... (Subfields)
/Free
In Lda; // Read the LDA without locking it
In Mydta; // Read MYDTAARA without locking it
In *Lock Mydta; // Read and lock MYDTAARA
Out Mydta; // Update and unlock MYDTAARA
In *Lock Mydta; // Read and lock MYDTAARA
Unlock Mydta; // Unlock MYDTAARA
/End-free
Log of Journal Entries |
|
Use this scrollable blog map to view other journal entries: |
|
| It is your responsibility to ensure procedures, techniques, and code used from this website are accurate and appropriate for your installation. No warranty or support is implied or expressed. |
![]() |
| Privacy and Email Policy |
| AS/400®, eServer, i5/OS, IBM i, Integrated Language Environment®, iSeries, OS/400®, RPG/400®, System i5, VisualAge®, and WebSphere® are trademarks of IBM Corporation. Note: IBM® System i is the latest member of the family of eServer iSeries. This site might refer to System i as System i5, iSeries, or AS/400. |
|
If you are having trouble navigating the menu at the top of this page, you may use the following scrollable site map instead: |
|
|











International visitors: