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:
'MYPGM'
'*LIBL/MYPGM'
'MYLIB/MYPGM'
DCL-F myfile HANDLER('MYPGM');
'MYSRVPGM(myProcecedure)'
'*LIBL/MYSRVPGM(myProcedure)'
'MYLIB/MYSRVPGM(myProcedure)'
DCL-F myfile HANDLER('MYLIB/MYSRVPGM(MyProc)');
DCL-F myfile HANDLER(handlerName) USROPN;
DCL-S handlerName CHAR(50);
handlerName = 'MYLIB/MYPGM';
OPEN myfile;
READ myfile;
CLOSE myfile;
handlerName = 'MYLIB/MYSRVPGM(myHandler)';
OPEN myfile;
READ myfile;
CLOSE myfile;
DCL-F myfile HANDLER(handlerPointer) USROPN;
DCL-S handlerPointer POINTER(*PROC);
handlerPointer = %PADDR('proc_a');
OPEN myfile;
READ myfile;
CLOSE myfile;
handlerPointer = %PADDR('proc_b');
OPEN myfile;
READ myfile;
CLOSE myfile;
DCL-F myfile HANDLER(myproc);
/COPY QOAR/QRPGLESRC,QRNOPENACC
DCL-PR myproc;
parm LIKEDS(QrnOpenAccess_T);
END-PR;
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.
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;
. . .
