RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Monitor errors using MONITOR Print E-mail
User Rating: / 1
Written by Chamara Withanachchi   

A monitor block starts with a MONITOR opcode; the program then process subsequent lines in the block, up to the first ON-ERROR opcode. If the code on the MONITOR block is processed without error, control passes to the first line following and ENDMON opcode. If, however one of the lines in the block causes an error control is passes to the appropriate ON-ERROR group.


The program/file status code determines which ON-ERROR group gains control. This is same status code that the %STATUS BIF provides. You can specify any status code from 00100 to 09999 or *PROGRAM, *FILE or *ALL. You can use *PROGRAM to generic program errors, *FILE for generic file errors or *ALL for all generic errors. Only one ON-ERROR group is processed – first one that covers the error status. It’s a good idea to place generic ON-ERROR groups after specific groups to ensure you’ve covered all possible errors. Once the ON-ERROR group is processed, control passes to the statement following the ENDMON operation.


You can specify monitor blocks anywhere in your program, including within IF, Do and SELECT groups – even nested with in the monitor blocks or ON-ERROR groups. Monitor blocks can also encompass IF, DO or SELECT groups.




      Dou  %EOF(File1Record);
         Read File1Record; 
          If %EOF(File1Record);
            Pay = (Hrs * Rate) + (Ohrs * rate +  1.8) + 
                  (DHrs * Rate + 3);
            Update File1Record;
   On-Error 1218;
      Dsply ‘Record is Locked’;
   On-Error 1011:1211:*FILE;
      Dsply ‘un-Expected File Error’;
   On-Error *PROGRAM;
      Dsply ‘Un-Expected program error’;
<Previous   Next>