Ü  %OPEN (File name)

·         It is used to check to see if a file has already been opened.

·         It returns *ON if the file is opened, otherwise it returns *OFF.

·         In case we are using USROPN keyword in F-Spec, then during the program initialization the file will be closed and we need to open it explicitly.

·         If we are not using the keyword USROPN then by default the file will be open during program initialization.


Example –%open built-in function in rpgle

FFILE1  IF   E           K DISK    USROPN
     c     LoadSub       BegSr
     c                   If        Not %Open(FILE1)
     c                   Open      FILE1
     c                   Endif
     c                   Eval      Idx=*Zero
     c                   DoU       %Eof(FILE1)
     c                   Read      FILE1
     c                   If        Not  %Eof(FILE1)
     c                   Eval      Idx=Idx+1
     c                   Eval      CRCD(Idx)=Field1
     c                   Eval      CRDS(Idx)=Field2
     c                   EndIf
     c                   EndDo
     c                   Close     FILE1
     c                   EndSr



User Comments:

Copyright © Go4as400.com, 2013-2017. Copyright notice