ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Record already locked error

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

  • Record already locked error

    When running this program I get the following message, but not every time.

    Record 258 member ATPWRK already locked to this job
    CPF5032 I/O error detected in ATPWRK (C G S D F)

    The file is a work file in QTEMP. I traced the statement to the READ operation in this segment of code. Any idea why it might be giving this error?
    Attached Files

  • #2
    Re: Record already locked error

    I would guess this is an update/add file and somewhere else in the program there is a read without an update. Because its a work file I would just make the file user open

    and

    if %open(myfile)
    close myfile
    open myfile
    endif

    before the loop (XCLWRK) where you are reading.
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Record already locked error

      Looks pretty straight forward. You might have a lock from a read or chain on the record from somewhere else in the program. When I have ran into this before, I usually make the file USROPN and do a close/open just before I clear. Depending on the size of the work file I would QCMDEXE a clrpfm or call a CL to do it if it was really big and didn't want all the extra IO.
      Goodbye

      Comment


      • #4
        Re: Record already locked error

        Its already a USROPN file. There are about 30 assorted SETLL, SETGT, CHAIN, READ, READE, READP commands on this file. (This is a huge legacy program from Mapics, 40,000+ lines of code). Bypassing the error simply moves the error to the next file operation.

        I would expect the READ in this subr to reset any locks. An update isn't required after a read. The next read simply resets. But, obviously, I am missing something here.

        Comment


        • #5
          Re: Record already locked error

          Check the chain(s) to make sure there is an update after each...
          and I remember some "system short fall" with commitment control and
          setll/setgt if the record not found the next record is locked..
          to get around it we did %found on the setll before the read.

          if your only getting the already locked message on the clear portion of the file, then you will be okay with the close/open.

          Jamie
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment

          Working...
          X