7.93.2 OPEN Comments / Warnings
-
When no specific OPEN command is coded for a file in an interactive RDML program, the file is opened as if an OPEN USE_OPTION(*FIRSTSCREEN) command was used.
-
When no specific OPEN command is coded for a file in a batch RDML program, the file is opened as if an OPEN USE_OPTION(*ONDEMAND) command was used.
-
Any OPEN command or request will be ignored if the file is already open. The exception to this rule is when the *OPNQRYF option is used. In this case the open file is closed, and then re-opened with the appropriate OPNQRYF parameters.
In addition, use of the *KEEPOPEN option against a file that is already open will cause the file to be flagged so that it can only be closed by a specific CLOSE command. The file is not actually closed and opened again (as with the *OPNQRYF option), but it is internally tagged so that it cannot be closed unless a specific CLOSE request command is issued.
There are 2 ways a file can be closed:
-
The first is by letting the normal RDML program termination logic CLOSE the file automatically.
-
The second is to issue a specific CLOSE command in the RDML program.
When an RDML program terminates normally it will attempt to automatically close all the database files it uses. However, if one or more of the following conditions apply the close request for a file will be ignored:
-
the file has already been closed or has never been opened.
-
the associated process has the usage HEAVY option.
-
the file has been previously opened with the *KEEPOPEN option.
-
the function attempting to close the file is not the one that originally opened the file.
-
A specific CLOSE command (ie: coded into the RDML program) will only be ignored if the file is already closed. In all other situations it will force the file to be closed, even if it was opened with the *KEEPOPEN option, or by some other program.
-
If any file is referenced by an RDML command before it is specifically opened (ie: by an OPEN command) or before the appropriate automatic open time has occurred (ie: a first screen interaction) it will be automatically opened on an "on demand" basis. What this means is that attempting any I/O operation against a closed file will merely result in the file being automatically opened.
-
When using USE_OPTION(*OPNQRYF) it is advisable to code a specific CLOSE into the RDML program. This will ensure that any temporary access path created by the OPNQRYF command is destroyed.
In addition, after using the *OPNQRYF option in combination with a specific KEYFLD parameter (other than the special *FILE parameter), it is advisable to only use a simple SELECT loop to read all records from the temporary access path created by the OPNQRYF command.
Attempting to use a SELECT command (or any other I/O command for that matter) that has a WITH_KEY parameter may produce unpredictable results because the file key being used by the I/O module does not match the actual key of the temporary file created by the OPNQRYF command.
-
When using the USE_OPTION(*FIRSTSCREEN) parameter the open "overlap" is attempted when the first screen is presented to the user. This screen is the first DISPLAY, REQUEST or POP_UP command that is actually executed in the program (which may not be the first one coded in the program).
Additionally, use of this option may cause a slight degradation over communication lines because it is not possible to use the DFRWRT (defer screen write until read) option in the associated IBM i display file.
Refer to the IBM i CRTDSPF command in the appropriate IBM supplied manual for more details of the DFRWRT parameter.
Attempting to manually change the display file to DFRWRT(*YES) will completely nullify the "overlap" feature and the user will have to wait until the file(s) are open before the first screen appears.