Accessory to WRKOBJLCK

CL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Here is a useful utility I wrote to have the system let me know when a file is not being used by anyone. It comes in handy when you have to replace a physical or logical file that's in production with the one that's been in testing. Since recompiling the file entails actually deleting the existing one, this cannot be done while someone is using it.

The Work With Object Locks (WRKOBJLCK) command will tell you who is using the file. My utility, Wait for File (WAITF), will run in the background and check every 30 seconds for you. WAITF will notify you with a break message when the file is available.

The utility ensures that the object exists and, if it does, attempts to allocate the object with a lock of *EXCL. Using the Monitor Message (MONMSG) command to determine if the allocation was successful or not is the key to how this utility works. (1 contains the WAITF command source code and 2 contains the source code for the CPP, F003CL.)

The utility ensures that the object exists and, if it does, attempts to allocate the object with a lock of *EXCL. Using the Monitor Message (MONMSG) command to determine if the allocation was successful or not is the key to how this utility works. (Figure 1 contains the WAITF command source code and Figure 2 contains the source code for the CPP, F003CL.)

If the allocation is successful, a break message is sent to the message queue from which the job was submitted. It is important to deallocate any object allocated. I do so as part of the utility, although you may wish to deallocate the object from the command line after you are done replacing or reorganizing the object.

- Andrew Longo


Accessory to WRKOBJLCK

Figure 1 The WAITF Command Source

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/WAITF) PGM(XXX/F003CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*==================================================================*/ WAITF: CMD PROMPT('Wait for File') PARM KWD(FILE) TYPE(QUAL) PROMPT('File') QUAL: QUAL TYPE(*NAME) LEN(10) MIN(1) QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) PROMPT('Library') 
Accessory to WRKOBJLCK

Figure 2 CPP F003CL

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/F003CL) SRCFILE(XXX/QCLSRC) */ /* */ /*==================================================================*/ F003CL: PGM PARM(&QUALFILE) DCL VAR(&QUALFILE) TYPE(*CHAR) LEN(20) DCL VAR(&FILE) TYPE(*CHAR) LEN(10) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&TYPE) TYPE(*CHAR) LEN(1) DCL VAR(&MSGQ) TYPE(*CHAR) LEN(10) DCL VAR(&MSGQLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSG) TYPE(*CHAR) LEN(40) RTVJOBA JOB(&MSGQ) TYPE(&TYPE) IF (&TYPE *EQ '1') THEN(DO) SBMJOB CMD(CALL PGM(F003CL) PARM(&QUALFILE)) + MSGQ(&MSGQ) GOTO CMDLBL(ENDPGM) ENDDO RTVJOBA SBMMSGQ(&MSGQ) SBMMSGQLIB(&MSGQLIB) CHGVAR VAR(&FILE) VALUE(%SST(&QUALFILE 1 10)) CHGVAR VAR(&LIB) VALUE(%SST(&QUALFILE 11 10)) CHKOBJ OBJ(&LIB/&FILE) OBJTYPE(*FILE) MONMSG MSGID(CPF9801) EXEC(DO) CHGVAR VAR(&MSG) VALUE('File' *BCAT &LIB *TCAT + '/' *CAT &FILE *BCAT 'was not found.') SNDBRKMSG MSG(&MSG) TOMSGQ(&MSGQLIB/&MSGQ) GOTO CMDLBL(ENDPGM) ENDDO TOP: ALCOBJ OBJ((&LIB/&FILE *FILE *EXCL)) WAIT(0) MONMSG MSGID(CPF1085 CPF1002) EXEC(DO) DLYJOB DLY(30) GOTO CMDLBL(TOP) ENDDO DLCOBJ OBJ((&LIB/&FILE *FILE *EXCL)) CHGVAR VAR(&MSG) VALUE('File' *BCAT &LIB *TCAT '/' + *CAT &FILE *BCAT 'is now available.') SNDBRKMSG MSG(&MSG) TOMSGQ(&MSGQLIB/&MSGQ) ENDPGM: ENDPGM 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: