ibm-midrangerpglerpg

Difference between WRITE and EXCEPT in rpg/rpgle


Hi in many of old rpg programs that I have come across I can see that EXCEPT is being used in place of WRITE opcode. Can someone tell me what is the exact difference between the EXCEPT and WRITE opcode.


Solution

  • For an internally described printer file "way back when", it was more common to use the "EXCPT" opcode instead of a "WRITE" opcode with a file record format. Although a label could be specified in the output record, no label was required in the calculation specification line of code. It could be left blank. Such as:

    C                      EXCPT
    

    Then, in the output specifications for the internally described printer file, output records with an "E" in the data type column would print (provided it also met any indicator requirements).

    OQSYSPRT      E          2   1
    O                FIELDA     24
    

    Pardon my attempt to simulate column spacing in free format. So, it was just a slightly easier way to output data to an internally described printer file.

    If you are coming across an older program that is using the "EXCPT" opcode to write to a data file, that purpose was to specifically update certain fields in a file record and not the whole record as would be done with a "WRITE" or "UPDATE" opcode.

    Hope that helps.

    Regards.