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.

01/07/08 - How to find more information about a command and its parms

When a command is prompted (F4) and displayed, position the cursor on the command title at the top of the screen and press F1 for Help.

To know more information about a command parameter, when the command is prompted, position the cursor on the parameter and press F1 for Help.

To know the list of values for a command parameter, when the command is prompted, position the cursor on the parameter and press F4 for List.


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.

12/22/08 - How to find commands when you know the action/verb

How to find commands when you know the action/verb you want such as ‘Save’ or the subject you want such as ‘Tape Device’

From a command line, press F4 to get the Major Command Groups menu. From this menu select the type of commands you want to see (i.e., option 2 will show Verb Commands, option 3 will show Subject Commands). From this list scroll through until you find the verb or subject you need and select the option. Now choose the option number, or type in the command name itself, which is displayed on the right hand side of the screen. The command is now displayed with parameters that are required to be entered.

Additionally, you can type "GO CMDXXX" at a command line (where XXX is replaced with SAV, WRK, DSP, TAP, LIN, etc.) to see all commands within groups.

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 2008, 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.

12/10/08 How to create a self-submitting CL program

Have you ever written a program that you did not want someone to be able to run interactively? The following code example can be used to create a CL program that will get submitted to batch even if it is called from a command line.

Note: The following is limited to programs with no parameters, but with some modification specific to the program, it can be made to process a program that has parameters.


PGM
/*********************************************************************/
/* Declare the program's file being used */
/*********************************************************************/
DCLF FILE(QADSPOBJ)

/*********************************************************************/
/* Declare program variables */
/*********************************************************************/
DCL &DEVICE *CHAR LEN(10) /* The job name running this pgm */
DCL &USER *CHAR LEN(10) /* The user running this pgm */
DCL &NBR *CHAR LEN(6) /* This job number */
DCL &TYPE *CHAR LEN(1) /* This job type */
DCL &MSGKEY *CHAR LEN(4) /* Message key for sbmjob routine*/
DCL &SENDER *CHAR LEN(80) /* The sender of a message */
DCL &PROGRAM *CHAR LEN(10) /* Program that sent a message */
DCL &CMD *CHAR LEN(1024) /* Cmd for QCMDEXC */
DCL &CMDLEN *DEC LEN(15 5) /* Length of command */
/*********************************************************************/
/* Declare standard error handling variables */
/*********************************************************************/
DCL &ERRORSW *LGL /* Standard error */
DCL &MSGID *CHAR LEN(7) /* Standard error */
DCL &MSG *CHAR LEN(512) /* Standard error */
DCL &MSGDTA *CHAR LEN(512) /* Standard error */
DCL &MSGF *CHAR LEN(10) /* Standard error */
DCL &MSGFLIB *CHAR LEN(10) /* Standard error */
DCL &KEYVAR *CHAR LEN(4) /* Standard error */
DCL &KEYVAR2 *CHAR LEN(4) /* Standard error */
DCL &RTNTYPE *CHAR LEN(2) /* Standard error */

/*********************************************************************/
/* Monitor for the global error to handle errors that are not */
/* specifically checked */
/*********************************************************************/
MONMSG MSGID(CPF0000) EXEC(GOTO STDERR1) /* Std err */

RTVJOBA JOB(&DEVICE) USER(&USER) NBR(&NBR) TYPE(&TYPE)
CHGVAR &CMDLEN VALUE(1024.0)
CHGVAR &CMD VALUE(' ')

/*********************************************************************/
/* If this program is called interactively submit it to batch */
/*********************************************************************/
IF (&TYPE = '1') THEN(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) TOPGMQ(*SAME) +
KEYVAR(&MSGKEY)
RCVMSG MSGTYPE(*INFO) MSGKEY(&MSGKEY) WAIT(*MAX) +
SENDER(&SENDER)
CHGVAR VAR(&PROGRAM) VALUE(%SST(&SENDER 27 10))
SBMJOB CMD(CALL PGM(&PROGRAM)) +
JOB(&PROGRAM) LOG(4 00 *SECLVL)
RCVMSG MSGTYPE(*COMP) MSGDTA(&MSGDTA) MSGID(&MSGID) +
MSGF(&MSGF) MSGFLIB(&MSGFLIB)
SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) TOPGMQ(*PRV) MSGTYPE(*COMP)
RETURN
ENDDO

/*********************************************************************/
/* Insert program code here */
/*********************************************************************/



END:
RETURN

/*********************************************************************/
/* Process the standard error handling routines */
/*********************************************************************/
STDERR1:
IF &ERRORSW SNDPGMMSG MSGID(CPF9999) +
MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
CHGVAR &ERRORSW '1' /* Set to fail on error */
RCVMSG MSGTYPE(*EXCP) RMV(*NO) KEYVAR(&KEYVAR)
STDERR2: RCVMSG MSGTYPE(*PRV) MSGKEY(&KEYVAR) RMV(*NO) +
KEYVAR(&KEYVAR2) MSG(&MSG) +
MSGDTA(&MSGDTA) MSGID(&MSGID) +
RTNTYPE(&RTNTYPE) MSGF(&MSGF) +
SNDMSGFLIB(&MSGFLIB)
IF (&RTNTYPE *NE '02') GOTO STDERR3
IF (&MSGID *NE ' ') SNDPGMMSG +
MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) MSGTYPE(*DIAG)
IF (&MSGID *EQ ' ') SNDPGMMSG +
MSG(&MSG) MSGTYPE(*DIAG)
RMVMSG MSGKEY(&KEYVAR2)
STDERR3: RCVMSG MSGKEY(&KEYVAR) MSGDTA(&MSGDTA) +
MSGID(&MSGID) MSGF(&MSGF) +
SNDMSGFLIB(&MSGFLIB)
SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE)
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 2008, 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.

12/3/08 How to see space location locks

Using option 12 of the DSPJOB command may not show an abnormal number of locks, (i.e. it might just show a few object-level locks being held by the job), but if you are having locking issues there may be many “space location” locks that you don’t see. A space location lock is a symbolic locking protocol.

Unfortunately, there is no way to see space location lock information from a 5250 green screen; however, there is a way to view this with iSeries Navigator. Using “My Connections” in Navigator:
1. Expand the system you are interested in
2. Go to: Work Management > Active Jobs
3. Right-click on the job in question
4. Go to: Details > Locked Objects
5. At the top of this screen, go to: View > Customize this View > Include
6. Select the box to include space location locks

This view will show all locks—object level locks and/or space location locks. To show details about an individual lock, simply right-click on the lock of interest and select Properties. That display will show you more detailed information (such as how many locks this job holds on that object). Additionally, the ‘Details’ tab shows the module, library, program and instruction that was executed to gain that lock.


To learn more about space location locks, go to: http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rzahw/rzahwsllco.htm


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 2008, 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.