Data Area Data Structure
From: Tim Phinney To: All
I need a date range in several RPG programs to determine processing. I didn't want to hard-code the date because the end date hasn't been determined. I created a data area with the date range in it and specified it as a Data Area Data Structure (i.e., UDS in the input specs). I ran the programs and thought I was hot stuff!
During testing, I happened to run a data entry program with this UDS from two different workstations and to my surprise I received an error message that the data area was locked. "Locked?" I said... "Help!" In my hurry, I assumed the data area was read-only. Does anyone have a solution?
From: Ernie Malaga To: Tim Phinney
Check my article, "The Versatile Data Area," in the February 1993 issue of MC. In case you don't have the article handy, I've reproduced the solution to your dilemma here as 2.
Check my article, "The Versatile Data Area," in the February 1993 issue of MC. In case you don't have the article handy, I've reproduced the solution to your dilemma here as Figure 2.
COMPANY is the actual name of the data area object (as it was created with the CRTDTAARA command), and INFO is the name of a data structure or field. In this case, INFO is a data structure into which the first 55 characters of COMPANY will be mapped.
The IN op code reads the data area without locking it. If you add *LOCK in Factor 1, the data area is locked by the job until (a) an OUT op code is processed, or (b) an UNLCK op code is processed.
The reason you're getting a locked data area with the UDS method is that when you code the "U" in column 18, the data structure is defined as an external data structure (external to the program-not externally defined, which is different). These data structures are always read automatically when the program starts, remain locked throughout, and are also updated automatically when the program ends, releasing the lock.
From: James Coolbaugh To: Tim Phinney
Another alternative to using a fixed data area is to use the local data area (LDA). This data structure is unique to every job, and its contents will be passed to any job that is submitted. I have found that the LDA is the best solution to use when you wish to pass information between programs, whether in the same job or to a submitted batch job. I have only created data area objects when I need to have a fixed value that is available across interactive jobs. Then I use the technique Ernie told you about. Use the IN and OUT keywords. It is always best not to use the UDS when handling data areas.
From: Tim Phinney To: James Coolbaugh
I considered the LDA, but decided against it because so many programs use the LDA for temporary passes. The program that needs the information may be a CALL from a CALLed program. It's too dangerous! Thanks for the quick response!
Data Area Data Structure
Figure 2 Explicit Read of a Data Area
... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 IINFO DS I 1 15 PHONE I 16 30 FAX I 31 55 CONT * C *NAMVAR DEFN COMPANY INFO C IN INFO ... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
LATEST COMMENTS
MC Press Online