Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Agenda
Using External Arrays Displaying or Editing an Array Printing Arrays Printing with Level Breaks Templating record structures Array Gotchas
External Arrays
Access to array shared by all programs in the same job Allows array contents to be passed from one program to
another
Array server program houses the contents of the array and
Array Services
Clear - calls DLTOBJ with no parameters to clear the array Create - calls CRTOBJ built over the array Change - calls CHGOBJ built over the array Delete - calls DLTOBJ built over the array Retrieve - calls RTVOBJ built over the array Count - calls RTVOBJ that reads all the records in the array,
Positioner parameters
Returns retrieved keys in separate Output parameters Non-key attributes are also returned in Output parameters
| Values FLD: One parameter per field RCD: One parameter for all fields KEY: One parameter for key fields only
SEL: Z-Details (field selection). F3=Exit F5=Reload F21=Copy from *Template
SEL: Usage: I-Input, O-Output, B-Both, N-Neither, D-Drop. Role: R-Restrict, M-Map, V-Vary length, P-Position. F3=Exit
SEL: Usage: I-Input, O-Output, B-Both, N-Neither, D-Drop. Role: R-Restrict, M-Map, V-Vary length, P-Position. F3=Exit
SEL: Usage: I-Input, O-Output, B-Both, N-Neither, D-Drop. Role: R-Restrict, M-Map, V-Vary length, P-Position. F3=Exit
10
> USER: Exit processing .-. . ** We didn't exit so we must have not found a "next" record . PGM.*Return code = CND.*Record does not exist . . ** Clear the output fields . PAR = CON By name . '
11
> USER: Process Data record .-. > Skip record matching positioning criteria; select any other . .-CASE . > Record matches positioning data . - c1 AND c2 AND c3 AND c4 AND c5 AND c6 . - c1: DB1.Scd Date U EQ PAR.Scd Date U . - c2: DB1.Lcn Cde EQ PAR.Lcn Cde . - c3: DB1.Com Cde EQ PAR.Com Cde . - c4: DB1.Grd Cde EQ PAR.Grd Cde . - c5: DB1.Carr Cde EQ PAR.Carr Cde . - c6: DB1.Leased Car? U EQ PAR.Leased Car? U . '. -*OTHERWISE . . ** Return the data . PAR = DB1 By name . . ** Return the keys of the record returned . PAR.Next Scd Date U = DB1.Scd Date U . PAR.Next Lcn Cde U = DB1.Lcn Cde . PAR.Next Carr Cde U = DB1.Carr Cde . PAR.Next Leased Car? U = DB1.Leased Car? U . PAR.Next Com Cde U = DB1.Com Cde . PAR.Next Grd Cde U = DB1.Grd Cde . . ** Exit after returning data . <-- *QUIT . '-ENDCASE '
12
services
A Service indicator Input parameter is necessary to request
13
? Condition *ALL values Build Change Clear Count Create Delete Retrieve Rtv Nxt
Type Op File/From value LST ** VAL B VAL H VAL L VAL O VAL C VAL D VAL R VAL N
Display/To value
B H L O C D R R
MN
14
| Values FLD: One parameter per field RCD: One parameter for all fields KEY: One parameter for key fields only
SEL: Z-Details (field selection). F3=Exit F5=Reload F21=Copy from *Template
15
SEL: Usage: I-Input, O-Output, B-Both, N-Neither, D-Drop. Role: R-Restrict, M-Map, V-Vary length, P-Position. Error: E-Flag Error. F3=Exit
16
passed to/from the Server program, and then moved into Output parameters
Must be built over a file other than *Arrays - only
18
19
records you need is in the file and, if not, creates the records
Create as an EXCEXTFUN so it can be called by functions
21
22
. | ** Create the next record in the sequence . | Chk Nbr - Nbr * . | > If found, quit building; if not found, create the record . | .-CASE . | -PGM.*Return code is *Normal . | *Exit Program - return code CND.*Normal . | -*OTHERWISE . | Create Nbr - Nbr * . | '-ENDCASE . | . | ** Decrement to prepare the next record . | LCL.Nbr next = LCL.Nbr next - CND.1 . | > Exit if we hit zero (or less) . | .-CASE . | -...NOT LCL.Nbr next is GT 0 . | *Exit Program - return code CND.*Normal . | '-ENDCASE . '-ENDWHILE . '-ENDCASE '-23
record user point to retrieve the array data for each displayed record
Build DSPFIL over Descending Nbr access path, positioning
24
DSPFIL details
In Initialize Subfile Control, Program Initialization, or a
previous program (if using external arrays), load the array in the most efficient manner
Count records in the array, either by making a pass through
array key(s)
In Initialize subfile record, use last array key(s) and call
25
28
29
. . . . . . . . . . . . . . . . . .
-*OTHERWISE ** No record returned from array, so EOF must have been hit. Set up to start reading the second array. ** Initialize keys for retrieving array records LCL.Last Scd Date U = CND.not specified LCL.Last Lcn Cde U = CND.*BLANK LCL.Last Com Cde U = CND.EQ *BLANK LCL.Last Grd Cde U = CND.*BLANK ** Trigger reading of second array LCL.Array being read U = CND.Second '-ENDCASE '-ENDCASE
. . . Continued from previous slide . . . > Handle reading of second array .-CASE -LCL.Array being read U is Second ** Read the next record Rtv Nxt ShScSmR - *Arrays * ** Flag the type of record that is on the screen RCD.Scd Dte Type U = CND.Range ** Process the record just read and perform record selection '-ENDCASE
Editing an array
Loading of the data into the subfile is just like in Displaying
an array
Calls to CRT/CHG/DLTOBJ functions are replaced by calls to
32
user point to retrieve the array data for each printed record
Use a Neither Positioner parameter to position on the Nbr file
33
34
35
be processed
PRTOBJs will require additional EXCUSRSRC functions
access path
All higher order key breaks are suppressed by moving the
37
WZA002
WZA003
38
communicating with other systems that use multi-format files or program described data structures
Use CVTVAR with the ELM context to move a field to the
39
> Build EDI format 722 .-. ** Clear EDI format array . Clr EDI format 722 - *Arrays * . . ** Build data by calling CRTOBJ . Crt EDI format 722 - *Arrays * . . ** Move array into structured field for parsing . PAR.EDI format 722 data = CVTVAR(ELM.EDI format 722 Arr) '--
40
Array Gotchas
Cannot use standard RTVOBJ to read through an array and
a RTVOBJ
Using CRTOBJ or DLTOBJ and generating RPG can result in
41