close

The EGL close statement disconnects a printer; or closes the file or message queue associated with a given record; or, in the case of an SQL record, closes the cursor that was opened by an EGL open or get statement.

Syntax diagram for the close statement
name
Name of the I/O object that is associated with the resource being closed; that object is a print form or an indexed, MQ, relative, serial, or SQL record
resultSetIdentifier
For SQL processing only, an ID that ties the close statement to a get or open statement run earlier in the same program. For details, see resultSetID.

Example:

	 if (userRequest == "C")
     try
       close fileA;
     onException
        myErrorHandler(12);
     end
	 end 

The behavior of a close statement depends on the type of I/O object that is associated with the resource being closed.

Indexed, serial, or relative record

When you use the name of an indexed, serial, or relative record in a close statement, EGL closes the file associated with that record.

If a file is open and you use the fileAssociation item to change the resource name associated with that file, EGL closes the file automatically before executing the next statement that affects the file. For details, see resourceAssociation.

EGL also closes any file that is open when the program ends.

On CICS® for z/OS®, these rules apply:
  • If you close a serial record associated with a spool file, EGL ensures that the CICS SPOOL CLOSE command is executed for that file
  • If you close a serial record that is not associated with a spool file or if you close an indexed or relative record, EGL performs a logical close on the file, which is then accessible by other programs
  • A close statement does not delete temporary storage files

MQ record

When you use the name of a MQ record in a close statement, EGL ensures that the MQSeries® command MQCLOSE is executed for the message queue associated with that record.

Print form

If the I/O object is a print form, the close statement issues a form feed and either disconnects from the printer or (if the print form is spooled to a file) closes the file.

Before you use ConverseVar.printerAssociation to change the print destination, close the printer or file specified by the current value of ConverseVar.printerAssociation. Issue a close statement option for each print destination, as multiple printer or print files can be open at the same time.

The EGL runtime ensures that all printers are closed when the program ends.

SQL record

When you use the name of an SQL record in a close statement, EGL closes the SQL cursor that is open for that record.

EGL automatically closes a cursor in these cases:

EGL closes all open cursors in this case:
  • The program is of type VGWebTransaction and presents a Web page
  • The program is of type textUI, does an automatic commit before conversing a form, and is unaffected by the option hold when the converse occurs; for details on textUI programs and the converse statement, see Segmentation
Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.