ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to remove Object lock for a particular job??

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

  • How to remove Object lock for a particular job??

    Hi All,

    My application work on single connection for I-Series (V4R5).
    When i switch from one application to another application, many objects from previous application still resides as '*SHRRD' held. Remember that i am not switching the job.

    Can any one tell me that how can i release Object lock (may be multiple lock on same object) for the given job. DLCOBJ cannot be the option, because i did not know what objects are held.

    #1. Is there any way to identify what objects are held for a particular job (Through programming)??

    #2. How can i remove object lock for the held objects??


    Thanks in advance
    SAM

  • #2
    Re: How to remove Object lock for a particular job??

    Further i have some information to this:

    "Retrieve Job Locks (QWCRJBLK) generates a list of objects that have been locked by the job or thread that is specified in the job identification information input parameter."

    Can any one tell me that how to use this API (QWCRJBLK)??
    SAM

    Comment


    • #3
      Re: How to remove Object lock for a particular job??

      See attached for full code

      Code:
      Retrieve Job Lock
      
           **  Program . . : CBX504
           **  Description : List job's object locks
           **  Author  . . : Carsten Flensburg
           **  Published . : Club Tech iSeries Programming Tips Newsletter
           **  Date  . . . : July 15, 2004
           **
           **
           **  Program description:
           **
           **    This program is intended to ease the process of retrieving the
           **    current job's list of object locks.  The information returned is
           **    object name, library and type as well as object lock state, similar
           **    to some of the information that is displayed by the DSPJOB or
           **    WRKJOB commands' Job Locks panel.  Running the command DSPJOB
           **    OPTION( *JOBLCK ) will show the information referred to above.
           **
           **    Program CBX504T is provided to give an example of how to call
           **    this program.
           **
           **  Parameters:
           **
           **    PxEntNbr    BOTH       The maximum number of job object lock entries
           **                           to return in the output array.  A maximum
           **                           of 128 job object lock entries can be returned.
           **
           **                           On return this parameter specifies the
           **                           actual number of job object locks loaded
           **                           in the second parameter.
           **
           **    PxLckEnt    OUTPUT     The list of job object lock entries are returned
           **                           in this parameter. The object name, library and
           **                           type as well as object lock state is returned
           **                           for each job object lock entry as illustrated
           **                           below:
           **
           **                1                           41                          81
           **                | -------- entry 1 -------- | -------- entry 2 -------- |
           **
           **                1      11     21     31     41     51     61     71     81
           **                | obj  | lib  | type | lock | obj  | lib  | type | lock |
           **
           **
           **-- Compilation specification:
           **
           **   CrtBndRpg   Pgm( 'library'/CBX504 )
           **               SrcFile( 'library'/QRPGLESRC )
           **               DbgView( *LIST )
           **
           **
           **-- Header specifications:  --------------------------------------------**
           H Option( *SrcStmt )
           **-- Api error data structure:  -----------------------------------------**
           D ERRC0100        Ds                  Qualified
           D  BytPro                       10i 0 Inz( %Size( ERRC0100 ))
           D  BytAvl                       10i 0 Inz
           D  MsgId                         7a
           D                                1a
           D  MsgDta                      256a
           **-- Global variables:  -------------------------------------------------**
           D Eix             s             10i 0
           D ApiRcvSiz       s             10u 0
           **-- Job lock information:  ---------------------------------------------**
           D JBLK0100        Ds                  Qualified  Based( pLstHdr )
           D  BytRtn                       10i 0
           D  BytAvl                       10i 0
           D  NbrObjLck                    10i 0
           D  OfsObjLck                    10i 0
           D  NbrLckObjRtn                 10i 0
           D  LckObjEntLen                 10i 0
           **
           D JBLK0100E       Ds                  Qualified  Based( pLstEnt )
           D  ObjNam                       10a
           D  ObjLib                       10a
           D  ObjTyp                       10a
           D  ObjExtAtr                    10a
           D  LckStt                       10a
           D                                2a
           D  LckSts                       10i 0
           D  MbrLcks                      10i 0
           D  LckCnt                       10i 0
           D  LckScp                        1a
           D                                3a
           D  ThrId                         8a
           D  ThrHdl                       10u 0
           ** V5R2:
           D  LckSpcId                     20a
           D  ObjAspNam                    10a
           D  ObjLibAspNam                 10a
           D  ObjAspNbr                    10i 0
           D  ObjLibAspNbr                 10i 0
           **-- Job id:  -----------------------------------------------------------**
           D JlJobId         Ds
           D  JiJobNam                     10a   Inz( '*' )
           D  JiUsrNam                     10a
           D  JiJobNbr                      6a
           D  JiIntJobId                   16a   Inz( *Blanks )
           D                                2a   Inz( *Allx'00' )
           D  JlThrInd                     10i 0 Inz( 3 )
           D  JlThrId                       8a
           **-- Retrieve job locks:  -----------------------------------------------**
           D RtvJobLck       Pr                  ExtPgm( 'QWCRJBLK' )
           D  JlRcvVar                  65535a         Options( *VarSize )
           D  JlRcvVarLen                  10i 0 Const
           D  JlFmtNam                      8a   Const
           D  JlJobId                      56a   Const
           D  JlFmtJobId                    8a   Const
           D  JlError                   32767a          Options( *VarSize )
           **
           D  JlLckFlr                     53a   Const  Options( *NoPass )
           D  JlFlrFmt                      8a   Const  Options( *NoPass )
           **-- Parameters:  -------------------------------------------------------**
           D PxEntNbr        s              5p 0
           D PxLckEnt        s             40a   Dim( 128 )
           **
           C     *Entry        Plist
           C                   Parm                    PxEntNbr
           C                   Parm                    PxLckEnt
           **
           **
           **-- Mainline:  ---------------------------------------------------------**
           **
           C                   Eval      ApiRcvSiz   = 10240
           C                   Eval      pLstHdr     = %Alloc( ApiRcvSiz )
           **
           C                   DoU       JBLK0100.BytAvl <= ApiRcvSiz  Or
           C                             ERRC0100.BytAvl  > *Zero
           **
           C                   If        ApiRcvSiz   < JBLK0100.BytAvl
           **
           C                   Eval      ApiRcvSiz   = JBLK0100.BytAvl
           C                   Eval      pLstHdr     = %ReAlloc( pLstHdr: ApiRcvSiz )
           C                   EndIf
           **
           C                   CallP     RtvJobLck( JBLK0100
           C                                      : ApiRcvSiz
           C                                      : 'JBLK0100'
           C                                      : JlJobId
           C                                      : 'JIDF0100'
           C                                      : ERRC0100
           C                                      )
           **
           C                   EndDo
           **
           C                   If        JBLK0100.NbrLckObjRtn > *Zero   And
           C                             ERRC0100.BytAvl       = *Zero
           **
           C                   ExSr      PrcJobLcks
           C                   Else
           **
           C                   Eval      PxEntNbr    = *Zero
           C                   EndIf
           **
           C                   DeAlloc                 pLstHdr
           **
           C                   Eval      *InLr       = *On
           C                   Return
           **
           **-- Process job locks:  ------------------------------------------------**
           C     PrcJobLcks    BegSr
           **
           C                   Eval      pLstEnt    = pLstHdr + JBLK0100.OfsObjLck
           **
           C                   For       Eix = 1  to JBLK0100.NbrLckObjRtn
           **
           C                   Eval      PxLckEnt(Eix) = JBLK0100E.ObjNam +
           C                                             JBLK0100E.ObjLib +
           C                                             JBLK0100E.ObjTyp +
           C                                             JBLK0100E.LckStt
           **
           **-- Specific exit point for this example:
           C                   If        Eix        = PxEntNbr              Or
           C                             Eix        = %Elem( PxLckEnt )     Or
           C                             Eix        = JBLK0100.NbrLckObjRtn
           **
           C                   Leave
           C                   EndIf
           **
           **-- General logic to keep entry pointer within list size:
           C                   If        Eix        < JBLK0100.NbrLckObjRtn
           C                   Eval      pLstEnt    = pLstEnt + JBLK0100.LckObjEntLen
           C                   EndIf
           C                   EndFor
           **
           C                   Eval      PxEntNbr    = Eix
           **
           C                   EndSr
      Attached Files
      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


      • #4
        Re: How to remove Object lock for a particular job??

        I just test the source, it's ok.

        I think one user can't remove locks on one's own initiative, except one user have all authorities to "ENDJOB" those locked jobs.
        Blog Liou


        The iSeries is such a good machine that it doesnâ??t sell services, the IBM insider believes.

        Plus, most of the IBM software youâ??d want or need already comes packaged with the box.

        If IBM really marketed it, everyone would buy it. ... But then IBM wouldnâ??t sell services, software, and reliability/backup.

        As it is, the customer is the best marketing the platform has.

        Comment


        • #5
          Re: How to remove Object lock for a particular job??

          Thanks for testing......You may still try dealloc or TRFJOB (or TFRJOB always transpose that one) Thanks also for the input on IBM I think we all feel the same way...Welcome to the forum, let me know If we can do anything for you.

          As always you are welcome to add anything to the site just send me what you have and Ill put a page together or use this link to post smaller code samples


          Welcome
          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


          • #6
            Re: How to remove Object lock for a particular job??

            Originally posted by sam400
            Hi All,

            My application work on single connection for I-Series (V4R5).
            When i switch from one application to another application, many objects from previous application still resides as '*SHRRD' held. Remember that i am not switching the job.

            Can any one tell me that how can i release Object lock (may be multiple lock on same object) for the given job. DLCOBJ cannot be the option, because i did not know what objects are held.

            #1. Is there any way to identify what objects are held for a particular job (Through programming)??

            #2. How can i remove object lock for the held objects??


            Thanks in advance

            Is this an application that you, or someone else in your shop, wrote? Do you have the source code?

            It sounds like your programs are opening files and then ending without closing those files. This is why they still have locks on the objects when you go to another program.

            Unless I misunderstand your description of the problem...

            Michael
            "Time passes, but sometimes it beats the <crap> out of you as it goes."

            Comment


            • #7
              Re: How to remove Object lock for a particular job??

              Originally posted by jamief
              Thanks for testing......You may still try dealloc or TRFJOB (or TFRJOB always transpose that one) Thanks also for the input on IBM I think we all feel the same way...Welcome to the forum, let me know If we can do anything for you.

              As always you are welcome to add anything to the site just send me what you have and Ill put a page together or use this link to post smaller code samples


              Welcome
              Jamie
              Yes,thanks a lot! I would often come here.
              Blog Liou


              The iSeries is such a good machine that it doesnâ??t sell services, the IBM insider believes.

              Plus, most of the IBM software youâ??d want or need already comes packaged with the box.

              If IBM really marketed it, everyone would buy it. ... But then IBM wouldnâ??t sell services, software, and reliability/backup.

              As it is, the customer is the best marketing the platform has.

              Comment

              Working...
              X