Explicit open and close calls to GSAM
IMS opens the GSAM data set when the first call is made and closes the data set when the application program terminates. Therefore, the application program does not usually need to make explicit open or close calls to GSAM.
However, explicit OPEN and CLSE calls are useful if:
- the application program loads a GSAM data set, and then in the same step reads the data set
using GSAM (for example, to sort the data set). The application program should issue the GSAM
CLSEcall after the load is complete. - the GSAM data set is an output data set, and it is possible that when the program executes it
does not make GSAM
ISRTcalls. A data set is not created. Subsequent attempts to read the nonexistent data set (using GSAM or not) will likely result in an error. To avoid this situation, explicitly open the data set. DL/I closes the data set when the step terminates. Closing the data set prevents the possibility of attempting to read an empty data set. - the GSAM data set is an output data set, and
data exists beyond the EOF address in the dataset control block (DSCB). The previous job/step may
have ended abnormally before the DSCB could be updated. If the program is restarted, but does not
make GSAM
ISRTcalls, the EOF will not be updated at job/step termination when DL/I closes the data set. This could strand any data that exists past the EOF address. To avoid this situation, explicitly open the data set so that the DSCB can be updated with the correct EOF address.
The explicit OPEN or CLSE call need not include an I/O area
parameter. Depending on the processing option of the PCB, the data set is opened for input or
output. You can specify that an output data set contain either ASA or machine control characters.
Including an I/O area parameter in the call and specifying OUTA in the I/O area indicates ASA
control characters. Specifying OUTM specifies machine control characters.