AS/400 >> Objects locks

by tom » Mon, 14 Nov 2005 16:38:21 GMT

Hi.
I was wondering if I can build sem CL procedre
which would first:
- check if physical file has lock on it
- if YES go to END, if NOT use RGZPFM on it
Does anybody has any idea ?

Reg.
Tom

AS/400 >> Objects locks

by walker.l2 » Mon, 14 Nov 2005 17:43:43 GMT


Have a look at the ALCOBJ command.


Walker.

AS/400 >> Objects locks

by Steve Richter » Mon, 14 Nov 2005 20:28:00 GMT


you can, but you have to call the list object locks API to do it -
QWCLOBJL

http://publib.boulder.ibm.com/iseries/v5r1/ic2924/info/apis/qwclobjl.htm

-Steve

AS/400 >> Objects locks

by James Pemberton » Mon, 14 Nov 2005 21:25:37 GMT

I used to have a procedure that would run on the weekends to handle exactly
what you are talking about. Instead of checking for object locks, just
monitor, and I can't remember the exact message, for the error message that
states the file is in use. If so, just reorganize the next file and so on.







----== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups ==----
Get Anonymous, Uncensored, Access to West and East Coast Server Farms!
----== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==----

AS/400 >> Objects locks

by Jim Thedorf » Mon, 14 Nov 2005 22:44:44 GMT

I use 2 CLs:


REORGALL:

*************** Beginning of data ********************************
START: PGM
DSPOBJD OBJ(*ALLUSR/*ALL) OBJTYPE(*FILE) +
OUTPUT(*OUTFILE) OUTFILE(MYLIB/OBJD)
MONMSG CPF0000
CALL MYLIB/REORGALLF
MONMSG CPF0000
ENDPGM
****************** End of data ***********************************


REORGALLF:

*************** Beginning of data *******************************
START: PGM
DCLF FILE(MYLIB/OBJD)
MONMSG CPF0000
RUNPROC: RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDPGM))
IF COND(&ODLBNM *NE 'MYLIB') THEN(DO)
IF COND(&ODOBAT *EQ 'PF') THEN(DO)
RGZPFM FILE(&ODLBNM/&ODOBNM)
MONMSG CPF0000
ENDDO
ENDDO
GOTO CMDLBL(RUNPROC)
ENDPGM: RETURN
ENDPGM
****************** End of data **********************************


Jim

AS/400 >> Objects locks

by tom » Tue, 15 Nov 2005 18:11:50 GMT

Hi.
I'm not sure if I understand your CL but
I think it would make RGZPFM command on all
files. It doesn't check if file is locekd or not.
Regards,
Tomasz



Jim Thedorf napisa?a):

AS/400 >> Objects locks

by poddys » Tue, 15 Nov 2005 21:04:49 GMT

I think the point of Jim's program is that he is using "MONMSG CPF0000"
to trap any file lock (or other) errors, rather than explicitly
checking to see if a file is in use - he didn't say that though in the
email. Yes the program does reorg all files in a library - it could be
he thought that was what you were trying to do. Still, it should be
easy to modify or extract from what he sent to do what you need.

I wish we could use the program - but to do that on our main JDE
production library would take the weekend and more...

AS/400 >> Objects locks

by Eb » Tue, 15 Nov 2005 21:52:56 GMT

RGZPFM FILE(mylib/myfile)
MONMSG CPF0000

The MONMSG when used in this fashion basically causes the program to
ingore any errors, such as not being able to lock the file.
Disadvantages the system will wait 30 seconds trying to lock the file.

---------------------------------------

RGZPFM FILE(mylib/myfile)
MONMSG CPF3202 EXEC (DO)
Put some source statements here
"
"
ENDDO

In this example if the file can't be lock an ERROR CPF3202 occurs the
statement in the Do/Enddo will execute. Again system wil try to lock
file for 30 seconds before failing and execute optional statements.

----------------------------------------
PGM

ALCOBJ OBJ((mylib/myfile *FILE *EXCL)) WAIT(1)
MONMSG MSGID(CPF1002) EXEC(GOTO CMDLBL(SKIP))
RGZPFM FILE(mylib/myfile)
DLCOBJ OBJ(mylib/myfile)

SKIP:

Program skips to here if unable to lock file

ENDPGM

In this example we try for 1 second to lock the file if successful we
RGZPFM, overwise skip past the Reorg. Advantage the program only waits
1 second to try and lock the file vs the 30 second system default.

AS/400 >> Objects locks

by Jim Thedorf » Wed, 16 Nov 2005 04:29:42 GMT

You could allocate the object with could add the following code:

ALCOBJ OBJ(((&ODLBNM /(&ODOBAT *FILE *EXCL)) WAIT(1)
MONMSG CPF1002

(note that if the object has a lock on it already then the CPF1002 will come
back to the program in 1 second.)

Once the reorg is done then use DLCOBJ to de-allocate.



Jim

AS/400 >> Objects locks

by Ken » Wed, 16 Nov 2005 12:53:05 GMT

Hi -




RGZPFM itself checks whether the member is locked.

This webpage I wrote doesn't speak directly to your question, but does
show some sample code for reorganizing multiple files/members in a
library. The code works fine, without any explicit lock checking.
http://www.ke9nr.net/iseries/faqs/reorgpf.shtml

If you want to avoid the full default wait time on a member in use,
you can use ALCOBJ as has already been mentioned, or you can change
the job's default wait time, which eliminates the need for
ALCOBJ/DLCOBJ. The latter is my preferred method.

--
Ken
http://www.ke9nr.net/
Opinions expressed are my own and do not necessarily represent the views
of my employer or anyone in their right mind.

AS/400 >> Objects locks

by Ren?H. Hartman » Thu, 17 Nov 2005 03:37:20 GMT

Starting with V5R3 you can reorganize files that are in use, even when
having a *SHRUPD lock.
Haven't used it on a heavy lib yet, don't know how it would affect your
JDE lib, but it might be useful to know this anyway...

--
Best regards,

Ren?H. Hartman
www.hac-maarssen.nl


"poddys" < XXXX@XXXXX.COM > schreef in bericht

CPF0000"
be

AS/400 >> Objects locks

by Karl Hanson » Wed, 21 Jun 2006 20:17:07 GMT


Another idea is to attempt ALCOBJ for the file/member before RGZPFM. If
you use lock state *EXCL and WAIT(0), a MONMSG can skip the RGZPFM step.
If the ALCOBJ succeeds, run RGZPFM and DLCOBJ to release the lock.

Similar Threads

1. Object lock during JDBC connection - AS/400

2. List Object Locks (QWCLOBJL) API

"The List Object Locks (QWCLOBJL) API generates a list of lock information 
about a specific object or database file member and places the list into the 
specified user space."

One of the items returned in the lock state. The V5R2 documentation says:

    "Lock state. The lock condition for the lock request. The possible 
values are:

    *NONE No lock exists.

    *SHRRD Lock shared for read.

    *SHRUPD Lock shared for update.

    *SHRNUP Lock shared no update.

    *EXCLRD Lock exclusive allow read.

    *EXCL Lock exclusive no read.

Can anyone explain under what circumstances I might get back *NONE?

Thanks, Sam




3. Work with Object Locks - AS/400

4. Cannot Change Signon Screen - Object Locked

Our "EX" IS manager changed the signon screen to something ridiculous
and we need to change it back to the default.
The original screen is QSYS/QDSIGNON but the new one is in
QGPL/QDSIGNON.
The object is locked by some system jobs though, so I cannot rename the
current one to make the QSYS one be the primary.
Is there a library higher up than QGPL at signon that I could put a new
member into, or is there a way to add a new library into the initial
library list so that the old QDSIGNON is not displayed?
That way, after our weekly IPL I would hope to not have any locks on
this member any more.
Thanks in advance...

5. SNDDST locking QDLS objects ? - AS/400

6. End Jobs which locks objects

Hi,

we use V5R2M0.

we should end jobs, which locks objects.

If i make an WRKOBJLCK, i see the jobs which locks the object, but i must 
manually end these jobs.

I can put the result of the WRKOBJLCK in a Print-File and put this printfile 
in an physical file.
Now i can read this file and end the jobs.

But at the next Release of the iSeries, it can happended, that IBM change 
the output in this printerfile. (other fields etc.)

Any other ideas, how can i end these jobs ?

Best Regards

Christian 


7. SAVLIB with locked objects - AS/400

8. How to see that an object is damaged -- object size

   The field ODOBSZ is deprecated.  The description of ODOBSZ, as seen 
in the request to DSPFFD QSYS/QADSPOBJ suggests to use instead, the 
following expression to calculate object size:  ODSIZU*ODBPUN

Karl wrote:
<<SNIP>>
> Off topic, but useful, to be able to see all objects by size in 
> descending order, do this:
> SELECT ODLBNM,ODOBNM,ODOBTP,ODOBSZ,ODOBTX FROM QGPL/DSPOBJD ORDER BY 4 DESC