Rules for the LIKEFILE keyword for prototyped parameters:

  • The filename parameter of the LIKEFILE keyword must be a file that has been previously defined on a File specification.
  • File specification keywords cannot be specified with the LIKEFILE keyword on a Definition specification. The file parameter uses all the settings specified by the File specification of the file specifed as the parameter of the LIKEFILE keyword.
  • No other Definition keywords can be specified other than OPTIONS(*NOPASS) or OPTIONS(*OMIT).
  • File parameters can be passed only between RPG programs and procedures. They are not compatible with file parameters from other programming languages, such as COBOL files, or files returned by the C fopen() or open() functions.
  • A file is always passed by reference. The called procedure works directly on the same file as the calling procedure. For example, if the caller reads a record, and the called procedure updates the record and returns, the caller cannot update the record again.
  • If the blocking attribute for the file cannot be determined from the File specification, the BLOCK keyword must be specified for the filename parameter.