01/28/09 How to change the object ownership of all objects in a library

The CHGOBJOWN command doesn't accept *ALL as an object name, but you can use a "UNIX-like" approach to the problem through the IFS representation of the i5/OS libraries:

CHGOWN OBJ('QSYS.LIB/yourlib.LIB/*.*') NEWOWN(newuser)


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2009, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

1/22/09 Send messages to all users attached to a group profile

Have you ever wanted to send a message to all users attached to a group profile? Here is a command and a CL program that you can use to do exactly that.


Note: Before you can compile the CL program SNDPGMMSG, you need to create a 132 character physical file named SPOOL132. That is done using this command: CRTPF /SPOOL132 RCDLEN(132)

SNDGRPMSG command

SNDGRPMSG: CMD PROMPT('Send Group Message')
PARM KWD(MSG) TYPE(*CHAR) LEN(512) EXPR(*YES) +
PROMPT('Message text, or')
PARM KWD(MSGID) TYPE(*CHAR) LEN(7) +
PROMPT('Message identifier')
PARM KWD(MSGF) TYPE(QUAL) PROMPT('Message file')
PARM KWD(MSGDTA) TYPE(*CHAR) LEN(512) EXPR(*YES) +
PROMPT('Message data field values')
PARM KWD(TOGRP) TYPE(*CHAR) LEN(10) PROMPT('To +
group profile')
QUAL: QUAL TYPE(*NAME) LEN(10)
QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) +
SPCVAL((*LIBL) (*CURLIB)) PROMPT('Library')



SNDPGMMSG CL program


PGM PARM(&MSG &MSGID &MSGFLB &MSGDTA &TOGRP)

DCL VAR(&MSG) TYPE(*CHAR) LEN(512)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&MSGFLB) TYPE(*CHAR) LEN(20)
DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(512)
DCL VAR(&TOGRP) TYPE(*CHAR) LEN(10)

DCL VAR(&MSGF) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&POS) TYPE(*DEC) LEN(3 0)

DCLF FILE(SPOOL132)

CHGVAR VAR(&MSGF) VALUE(%SST(&MSGFLB 1 10))
CHGVAR VAR(&MSGFLIB) VALUE(%SST(&MSGFLB 11 10))

DSPUSRPRF USRPRF(&TOGRP) TYPE(*GRPMBR) OUTPUT(*PRINT)
MONMSG MSGID(CPF0000) EXEC(DO)
SNDUSRMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('No +
messages sent to group profile' *BCAT +
&TOGRP) MSGTYPE(*INFO) TOUSR(*REQUESTER)
RETURN
ENDDO

CRTDUPOBJ OBJ(SPOOL132) FROMLIB(*LIBL) OBJTYPE(*FILE) +
TOLIB(QTEMP)
CPYSPLF FILE(QPUSRPRF) TOFILE(QTEMP/SPOOL132) +
SPLNBR(*LAST)
DLTSPLF FILE(QPUSRPRF) SPLNBR(*LAST)
CPYF FROMFILE(QTEMP/SPOOL132) +
TOFILE(QTEMP/SPOOL132A) MBROPT(*REPLACE) +
CRTFILE(*YES) INCCHAR(*RCD 1 *EQ ' ')
DLTF FILE(QTEMP/SPOOL132)
CPYF FROMFILE(QTEMP/SPOOL132A) +
TOFILE(QTEMP/SPOOL132B) MBROPT(*REPLACE) +
CRTFILE(*YES) INCCHAR(*RCD 49 *EQ ' ')
DLTF FILE(QTEMP/SPOOL132A)
OVRDBF FILE(SPOOL132) TOFILE(QTEMP/SPOOL132B)
READLOOP:
RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDJOB))
CHGVAR VAR(&POS) VALUE(2)
MSGLOOP:
IF COND(&POS *LE 106) THEN(DO)
IF COND(%SST(&SPOOL132 &POS 1) *NE ' ') THEN(DO)
IF COND(&MSG *NE ' ') THEN(DO)
SNDUSRMSG MSG(&MSG) MSGTYPE(*INFO) +
TOUSR(%SST(&SPOOL132 &POS 10))
MONMSG MSGID(CPF0000)
ENDDO
ELSE CMD(IF COND(&MSGID *NE ' ') THEN(DO))
SNDUSRMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) MSGTYPE(*INFO) +
TOUSR(%SST(&SPOOL132 &POS 10))
MONMSG MSGID(CPF0000)
ENDDO
ENDDO
ELSE CMD(DO)
GOTO CMDLBL(READLOOP)
ENDDO
CHGVAR VAR(&POS) VALUE(&POS + 26)
GOTO CMDLBL(MSGLOOP)
ENDDO
GOTO CMDLBL(READLOOP)
ENDJOB:
DLTOVR FILE(SPOOL132)
DLTF FILE(QTEMP/SPOOL132B)
ENDPGM


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2009, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

01/14/09 How to determine a lock on an IFS object

Many times when enrolling an Integrated File Systems (IFS) object into journaling a message appears stating the attempt was unsuccessful. Typically this outcome occurs because of locks. Unfortunately, there is no WRKOBJLCK command for IFS so an API is needed to display all the jobs that have a lock on an IFS object.

Call the API program: CALL QP0FPTOS PARM(*LSTOBJREF '/ifspath/ifsfile' *FORMAT2)

You will need *SERVICE authority to call this API.

This API will output a detailed spooled file with all the jobs that have a lock(s) on that IFS object and the type of lock that exists.

Note: the third character (from the left) in the API object name is a ‘zero’ and the seventh character is an alpha letter ‘O’.


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2009, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.