Results 1 to 13 of 13

Thread: File Lock

  1. #1
    Code400 Newbie
    Join Date
    May 2007
    Location
    India
    Posts
    20
    Rep Power
    0

    File Lock

    I'm experiencing a lock on a member in a file. The message I receive is,
    "Member (file name) already in use." The lock is apparently created
    by a RPG program .

    I cannot find any way to release the lock. I've tried DLCOBJ for all levels
    (*SHRRD/*EXCL/etc.) for both the physical and the logical file involved.

    Nothing seems to work -- except logging off and logging back on
    again.

  2. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

  3. #2
    Analyst ReachKrishna's Avatar
    Join Date
    Mar 2005
    Location
    India
    Age
    32
    Posts
    198
    Rep Power
    1121

    Re: File Lock

    If the lock is being set by the RPG program please check how the RPG pgm is returning back the control to the calling program.

    If the program is just doing a RETURN and not setting on LR indicator before returning back the control then the lock would remain. You have to have a SETON LR statement before RETURN statement.
    Regards,
    KR

  4. #3
    SuperMan as400Pro's Avatar
    Join Date
    Mar 2006
    Location
    Dobrovelychkivka, Kirovohrads'ka, Ukraine
    Posts
    353
    Rep Power
    1360

    Re: File Lock

    besides LR if you chain to a file when its an update file
    you must release the lock prior to leaving the program or a
    lock will remain.

    you can chain with a no-lock

    chain(n) (key1:key2) somefile

    or you can use the unlock opcode on the file...
    I'm here to chew bubble gum and kick @#%@#%@#%.....and I'm all outta bubble gum !
    Yes I'm talking to you squirrel nuts.

  5. #4
    Analyst
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    1,585
    Rep Power
    9573

    Re: File Lock

    Hi,

    yet an other question:
    Are you files registered in a journal and are you working with commitment control?
    A row/record locked under commitement controls can only be released by executing a Commit (for confirmation) or Rollback (for resetting).

    Btw a record locked under commitment control cannot be released with the (N)-extention in RPG!

    Birgitta

  6. #5
    Code400 Newbie
    Join Date
    May 2007
    Location
    India
    Posts
    20
    Rep Power
    0

    Re: File Lock

    hi.,


    Thank you guys fior your reply for my query..

    but still i didn't get the solution for that..

    ReachKrishna : Krishna I am Setting ON the LR indicator.

    as400Pro: I used that file in the input mode only not in the update mode..

    B.Hauser : no journel is attached to that file.

    regards .,

    Mukundan.M

  7. #6
    Analyst MikeS's Avatar
    Join Date
    Oct 2005
    Location
    Cardiff, South Wales
    Age
    45
    Posts
    221
    Rep Power
    1489

    Re: File Lock

    Hi,

    It wasn't clear intially, but is the message "locked to this job" or simply "Already in use".

    If it is the later then this means that some other job, process or user is using this member. You can find out what is locking the member by using WRKOBJLCK for the file in question.

    If it is the former then either your current program or a called/calling program is holding a lock. A combination of the things mentioned in the other responses should help you resolve this.

    HTH

    Mike

  8. #7
    Code400 Newbie
    Join Date
    May 2007
    Location
    India
    Posts
    20
    Rep Power
    0

    Re: File Lock

    hi mike.,

    i got the later one. that is 'Already in use'.

    i checked with WRKOBJLCK. the PF is being locked by RPG program. with lock status *SHRRD. and my RPG only Reads the physical does not updates.

    what i am trying to do is..

    in one session i am running a RPG program.
    in another session i am trying to clear the physicial file using CLRPFM command which was used for input in the above RPG program.

    I got the following error message.

    Message ID . . . . . . : CPF3156
    Date sent . . . . . . : 07/09/06 Time sent . . . . . . : 14:36:57

    Message . . . . : File BFD in library MUKUNDAN in use.

    Cause . . . . . : Either the initialize physical file member (INZPFM)
    command or the clear physical file (CLRPFM) command failed because the file
    is being processed in another job or thread within your job.
    Recovery . . . : Allocate the file (ALCOBJ command) and then try either the
    INZPFM or the CLRPFM command again.

  9. #8
    Analyst MikeS's Avatar
    Join Date
    Oct 2005
    Location
    Cardiff, South Wales
    Age
    45
    Posts
    221
    Rep Power
    1489

    Re: File Lock

    You cannot clear a File in one job while it is being accessed by another job, regardless of whether that file is open for input or update.

    CLRPFM needs an "Exclusive" lock to work. Therefore you cannot do this.

    You would need to end the job on the first session before the CLRPFM would work.

  10. #9
    Code400 Newbie
    Join Date
    May 2007
    Location
    India
    Posts
    20
    Rep Power
    0

    Re: File Lock

    Thank you Mike..

    is there is any way to read a file without locking it, in RPG?

  11. #10
    Analyst MikeS's Avatar
    Join Date
    Oct 2005
    Location
    Cardiff, South Wales
    Age
    45
    Posts
    221
    Rep Power
    1489

    Re: File Lock

    The problem here is that you need to distinguish between "File Locking" and "Record Locking"

    When a program starts that uses a file in RPG a basic Lock is applied to the file in all cases. This basically tells the system that this program is using the file, doesn't matter if it's input or update mode.

    Declaring the file as input or update, tells the program how to handle "record" level locking. i.e. the record will not be locked in Input mode but will be locked in Update mode.


    The question I would ask is "Why would you need a program to Clear the file while users or another program is viewing it?"

    If the Clearing of the file is part of an End of Day process then some sort of check on open jobs and a way of closing them first would be required.

    HTH

    Mike

  12. #11
    Experienced Forum Member arrow483's Avatar
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    1,741
    Rep Power
    4217

    Cool Re: File Lock

    You can clear a file that is in use, provided a record lock is not in place. You need to use SQL

    DELETE FROM myfile

    This will delete all records from the file, and does not require exclusive access. The SQL statement can be imbeddded in RPG or run seperately.

  13. #12
    Noffascropulan gcraill's Avatar
    Join Date
    Mar 2006
    Location
    Hamilton
    Age
    47
    Posts
    1,549
    Rep Power
    3446

    Re: File Lock

    Quote Originally Posted by arrow483 View Post
    DELETE FROM myfile
    Depending on the size of the file this still hogs space, with the SQL delete, the records are flagged as deleted but still exist in the file - assumedly this takes up disk space ?

    Total records . . . . . . . . . . . . . . : 0
    Total deleted records . . . . . . . . . . : 124


    But with the CLRPFM command it gets rid of the deleted records as well.

    Total records . . . . . . . . . . . . . . : 0
    Total deleted records . . . . . . . . . . : 0


    GC

  14. #13
    Analyst Zdenko's Avatar
    Join Date
    Jun 2005
    Location
    Ziri, Slovenia
    Age
    57
    Posts
    195
    Rep Power
    1172

    Re: File Lock

    Hi

    There is a parameter on CRTPF/CHGPF that may be usable:
    REUSEDLT(*YES)
    LP Zdenko

  15. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Age
    21
    Posts
    1,000,000
     

Facebook Comments


Similar Threads

  1. Regarding Journaling
    By Sandeep D in forum RPG/RPGLE
    Replies: 3
    Last Post: November 16th, 2009, 07:37 AM
  2. Regd moving
    By sudha in forum Iseries System administration
    Replies: 4
    Last Post: April 26th, 2007, 09:17 AM
  3. reg RLU
    By shankar.as400 in forum ANY THING GOES
    Replies: 7
    Last Post: April 5th, 2006, 11:18 PM
  4. OVRDBF and Activation Groups.
    By coder400 in forum CLP/CLLE
    Replies: 8
    Last Post: December 12th, 2005, 09:56 AM
  5. CPF4102 error
    By jane22 in forum RPG/RPGLE
    Replies: 17
    Last Post: August 12th, 2005, 08:32 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •