Wouldn't life be easier if the field names on the display file matched the field names in the physical file? To display the values in the database using RPG, the program would simply CHAIN to the file before the EXFMT.
The problem is, when the program is updating the file, the record is locked. It would be advantageous if the record could be shared by multiple users. You can accomplish this by specifying an N in column 53 on the CHAIN op code so the record isn't locked.
When the display fields are modified and the user wants to update the record, the program must CHAIN to the record again and lock the record. Since the field names are the same, the second CHAIN would destroy the displayed values. This explains why many programs have hundreds of lines of code that do nothing more than move data fields.
There is an easier way; use a multiple occurrence data structure. Simply name a data structure, specify E in position 17 to indicate that the subfields are externally described, use the same file name as in the F-specs, and insert a 2 for the number of occurrences. Prior to the update, use the OCUR op code as shown in 8.
There is an easier way; use a multiple occurrence data structure. Simply name a data structure, specify E in position 17 to indicate that the subfields are externally described, use the same file name as in the F-specs, and insert a 2 for the number of occurrences. Prior to the update, use the OCUR op code as shown in Figure 8.
The first OCUR op code points to the second occurrence of the data structure to preserve the field values on the screen. This technique simplifies coding; the field names on the screen are consistent with the field names in the file, and you can use another feature of the AS/400; referencing the field definitions in the display file.
Another approach to this problem is to use the RTNDTA display file keyword. See the DDS Reference manual (SC41-9620) for additional information.
Matching Field Names
Figure 8 Using Display File Field Names with OCUR
*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+.. C 2 OCUR DSNAME C KEY CHAINFNAME 88 C 1 OCUR DSNAME C *IN88 IFEQ *OFF C UPDATRECNAM C ENDIF
LATEST COMMENTS
MC Press Online