Start of change

HANDLER(program-or-procedure { : communication-area)})

The HANDLER keyword indicates that the file is an Open Access file. It can be specified for files with device DISK, PRINTER, SEQ, or WORKSTN.

The first parameter specifies the program or procedure that handles the input and output operations for the file. It can be specified in the following ways:

Note:

The second parameter is optional. It specifies a variable that is passed to the handler to allow the RPG program to share additional information directly with the handler.

In the following example, the handler expects the communication area to be a data structure with a 10-character option subfield.
Note: It is up to the RPG programmer to define the communication area variable the way the handler expects it. Usually, a copy file would be used to define a template data structure for the communication area. See Example of an Open Access Handler for a complete example of an Open Access file that shows how to use a copy file to ensure that the RPG program and the handler use the same definition for the communication area.
   DCL-F myfile HANDLER('MYPGM' : options) USROPN;

   DCL-DS options QUALIFIED;
      detail CHAR(10);
   END-DS;

   options.detail = 'FULL';
   OPEN myfile;
   . . .
   CLOSE myfile;

   options.detail = 'NONE';
   OPEN myfile;
   . . .
End of change