ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Error handling on a read or chain

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error handling on a read or chain

    If I have my file as an update i.e.

    Code:
    fIIML01    Uf   e           k disk
    When I read or chain to a record in the file. Is there a way I can tell if it is in use by another process that is updating the record?

    Thanks,

    DAC

    Has anyone ever used the %Status command:

    Use %Status built in Function or File Information Data Structure to check record lock.

    Code:
    If %Status(EMP) = 1217
    Errmsd = Record Lock
    EndIf
    Where EMP is Physical File name.

    I tried this method:
    Code:
    fIIML02    Uf   e           k disk                    
    F                                     INFDS(FIDS01)   
    D FIDS01          DS                        
    D  STS01            *STATUS                 
    D  REC01                397    400B 0
    If another process has a lock on the IIML02 file. The status should be 1216?

    DAC

  • #2
    Re: Error handling on a read or chain

    PLEASE USE CODE TAGS!!! maybe this will help you out http://www.as400network.com/resource...ageView=Search
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: Error handling on a read or chain

      Code:
      chain(e) Employee# Emp;
      if %error;
        Select;
          when %Status( Emp ) = 1218
            // * if you are here, you have a record lock
          other;
            // * if you are here, you have some other error besides a record lock
        endsl;
      endif;

      You need to use the (e) extender on the chain / read / etc. If there is an error, such as a record lock, you can then trap it with the %error bif. Then you can check the %status to see if it's 1218, which would indicate a record lock.

      You will not get the error generated until the maximum record wait time is reached for the file. (The default is 60 seconds I believe) You can override the file to lower this value in order to trap the error more quickly, so that a user isnt sitting for a minute with a locked up screen if they have a record lock.
      Last edited by MichaelCatalani; February 24, 2010, 04:41 PM.
      Michael Catalani
      IS Director, eCommerce & Web Development
      Acceptance Insurance Corporation
      www.AcceptanceInsurance.com
      www.ProvatoSys.com

      Comment

      Working...
      X