News Stay informed about the latest enterprise technology news and product updates.

Program to end a user's session

Program to end a user's session





/* The ABTOBJUSR command aborts users that are accessing the        */
/*   object in question.                                            */
/*                                                                  */
/* The CPP is the CL program ABTOBJUSRN which calls another CLP     */
/*   program ABTOBJUSRX.                                            */
/*                                                                  */
/*   CHGCMD CMD(ABTOBJUSR) PGM(YOUR_LIB/ABTOBJUSRN)                 */
/*                                                                  */
          CMD        PROMPT('Abort Object User Profiles')
          PARM       KWD(OBJ) TYPE(QUAL) MIN(1) +
                        SNGVAL((*NONE)) PROMPT('Object')
          PARM       KWD(OBJTYPE) TYPE(*CHAR) LEN(7) MIN(1) +
                        PROMPT('Object type')
          PARM       KWD(MBR) TYPE(*NAME) LEN(10) DFT(*NONE) +
                        SPCVAL(*FIRST *NONE) +
                        PROMPT('Member')
          PARM       KWD(DELAY) TYPE(*CHAR) LEN(3) DFT(30) +
                        RANGE(30 900) PROMPT('Delay Time in seconds')
 QUAL:    QUAL       TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES)
          QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +
                     SPCVAL((*LIBL)) EXPR(*YES) PROMPT('Library +
                        name')
     A*
     /*  Member .....: CUPDSP                                      */
     /*  Member type : DDS                                         */
     /*  Description : Physical file of CUPLCK Records             */
     /*  Compile ....: CRTPF  FILE(QGPL/CUPLCK)  +                 */
     /*                  SRCFILE(YOURLIB/QDDSSRC)                  */
     A*                                                               *
     A          R RLCK
     A            FLD1          14
     A            DSPDEV        10
     A            FLD2           1
     A            DSPUSR        10
     A            FLD3           1
     A            DSPNBR         6
     A*
     /*  Member .....: CUPLCK1                                     */
     /*  Member type : DDS                                         */
     /*  Description : Physical file of CUPLCK1 Records            */
     /*  Compile ....: CRTPF  FILE(QGPL/CUPLCK1)  +                */
     /*                  SRCFILE(YOURLIB/QDDSSRC)                  */
     A*                                                               *
     A          R RLCK
     A            DSPDEV        10
     A            DSPUSR        10
     A            DSPNBR         6
     A*
     /*  Member .....: CUPLCK2                                     */
     /*  Member type : DDS                                         */
     /*  Description : Physical file of CUPLCK2 Records            */
     /*  Compile ....: CRTPF  FILE(QGPL/CUPLCK2) +                 */
     /*                  SRCFILE(YOURLIB/QDDSSRC)                  */
     A*                                                               *
     A          R RLCK
     A            DSXDEV        10
     A            DSXUSR        10
     A            DSXNBR         6
     A*
     /*  Member .....: CULDSP                                      */
     /*  Member type : DDS                                         */
     /*  Description : Logical view of CUPDSP Records              */
     /*  Compile ....: CRTLF  FILE(QGPL/CULLCK)  +                 */
     /*                  SRCFILE(YOURLIB/QDDSSRC)                  */
     A*                                                               *
     A                                      DYNSLT
     A          R RDSP                      PFILE(CUPLCK)
     A            DSPDEV
     A            DSPUSR
     A            DSPNBR
     A          S DSPDEV                    COMP(NE '          ')
     A            DSPNBR                    COMP(NE ' Lock')
     A            DSPNBR                    COMP(NE '*SHRRD')
     A            DSPNBR                    COMP(NE 'Number')
     A            DSPNBR                    COMP(NE 'brary ')
     A            DSPNBR                    COMP(NE 'Object')
     A            DSPNBR                    COMP(NE '  Work')
/*                                                                  */
/*  Member .....: ABTOBJUSRN                                        */
/*  Member type : CLP                                               */
/*                                                                  */
/********************************************************************/
/*                                                                  */
/*  ABTOBJUSRN - ABORT OBJECT USER PROFILE                          */
/*             1.THIS COMMAND PERFORMS A WRKOBJLCK TO A FILE        */
/*               AND THEN PERFORMS A CPYSPLF TO A FILE CUPLCK       */
/*             2.THE FILE IS MANIPULATED AND THEN PROGRAM CONTROL   */
/*               IS PASSED TO CLP ABTOBJUSRX                        */
/*             3.THE PROGRAM PASSES THROUGH TWICE ONCE TO SEND      */
/*               MESSAGES FROM ABTOBJUSRX AND THEN TO INITIATE      */
/*               ENDJOBS THROUGH PROGRAM ABTOBJUSRX                 */
/*             4.MESSAGES AND DELAYS CAN BE SENT FOR 30-900 SECONDS */
/*                                                                  */
/*  Compile ....: CRTCLPGM PGM(QGPL/ABTOBJUSRN)      +              */
/*                  SRCFILE(YOURLIB/QCLSRC)                         */
/*                                                                  */
/*  DATE WRITTEN - 07/15/02                                         */
/*  WRITTEN BY   - D.BEECH                                          */
/*                                                                  */
/********************************************************************/

             PGM        PARM(&FULLOBJ &TYPE &MBR &DELAY)
             DCL        VAR(&FULLOBJ)   TYPE(*CHAR) LEN(20)
             DCL        VAR(&OBJ)       TYPE(*CHAR) LEN(10)
             DCL        VAR(&LIBL)      TYPE(*CHAR) LEN(10)
             DCL        VAR(&TYPE)      TYPE(*CHAR) LEN(07)
             DCL        VAR(&MBR)       TYPE(*CHAR) LEN(10)
             DCL        VAR(&DELAY)     TYPE(*CHAR) LEN(03)
             DCL        VAR(&PASS)      TYPE(*CHAR) LEN(01)
             DCL        VAR(&MSG)       TYPE(*CHAR) LEN(117)
             CHGVAR     VAR(&OBJ)  VALUE(%SST(&FULLOBJ 1 10))
             CHGVAR     VAR(&LIBL) VALUE(%SST(&FULLOBJ 11 10))
             CHGVAR     VAR(&MSG)  VALUE('The files that you are +
                          accessing may delay a critical MIS job +
                          from running. Please sign off the system +
                          in     seconds')
             CHGVAR     VAR(%SST(&MSG 107 3)) VALUE(&DELAY)
             CHGVAR     VAR(&PASS) VALUE('1')

/********************************************************************/
/* WRKOBJLCK - OBJECT LOCKS WRITTEN TO A SPOOLFILE AND THEN TO A    */
/*             PHYSICAL FILE                                        */
/********************************************************************/

 START:      WRKOBJLCK  OBJ(&LIBL/&OBJ) OBJTYPE(&TYPE) MBR(&MBR) +
                          OUTPUT(*PRINT)
             MONMSG     MSGID(CPF9898) EXEC(GOTO CMDLBL(EXIT))
             CLRPFM     FILE(QGPL/CUPLCK)
             CLRPFM     FILE(QGPL/CUPLCK1)
             CLRPFM     FILE(QGPL/CUPLCK2)
             MONMSG     MSGID(CPF0000)
             CPYSPLF    FILE(QPDSPOLK) TOFILE(QGPL/CUPLCK) +
                          SPLNBR(*LAST)
             DLTSPLF    FILE(QPDSPOLK) SPLNBR(*LAST)
             CPYF       FROMFILE(QGPL/CULLCK) TOFILE(QGPL/CUPLCK2) +
                          MBROPT(*REPLACE) CRTFILE(*NO) FMTOPT(*NOCHK)
/********************************************************************/
/* OPNQRYF - FILE IS SUMMARIZED TO HAVE ONE ENTRY FOR EACH DEVICE,  */
/*           USER, AND JOB NUMBER                                   */
/********************************************************************/
             OVRDBF     FILE(CUPLCK2) SHARE(*YES)
             OPNQRYF    FILE((CUPLCK2)) GRPFLD(DSXDEV DSXUSR +
                          DSXNBR) MAPFLD((DSPDEV '%MAX(DSXDEV)') +
                          (DSPUSR '%MAX(DSXUSR)') (DSPNBR +
                          '%MAX(DSXNBR)'))
             CPYFRMQRYF FROMOPNID(CUPLCK2) TOFILE(QGPL/CUPLCK1) +
                          MBROPT(*REPLACE) FMTOPT(*NOCHK)
             CLOF       OPNID(CUPLCK2)
/********************************************************************/
/* ON FIRST PASS =  1 CALL ABTOBJUSRX TO SEND MESSAGES TO USER THAT */
/*                   SESSION WILL BE ABORTED                        */
/* ON SECOND PASS = 2 CALL ABTOBJUSRX TO INITIATE AN ENDJOB         */
/********************************************************************/
             IF         COND(&PASS *EQ '1') THEN(DO)
             CALL       ABTOBJUSRX PARM(&FULLOBJ &TYPE &MBR &DELAY &PASS)
             CHGVAR     VAR(&PASS) VALUE('2')
             GOTO CMDLBL(START)
             ENDDO
             IF         COND(&PASS *EQ '2') THEN(DO)
             CALL       ABTOBJUSRX PARM(&FULLOBJ &TYPE &MBR &DELAY &PASS)
             ENDDO
/********************************************************************/
/* END OF PROGRAM                                                   */
/********************************************************************/
      EXIT:  ENDPGM
/*                                                                  */
/*  Member .....: ABTOBJUSRX                                        */
/*  Member type : CLP                                               */
/*                                                                  */
/********************************************************************/
/*                                                                  */
/*  ABTOBJUSRX - SEND MESSAGES OR INITIATE ENDJOB                   */
/*             1.THIS PROGRAM SENDS A MESSAGE ON PASS = 1           */
/*               AND THEN INITIATES AN ENDJOB ON PASS = 2           */
/*                                                                  */
/*  Compile ....: CRTCLPGM PGM(QGPL/ABTOBJUSRX)      +              */
/*                  SRCFILE(YOURLIB/QCLSRC)                         */
/*                                                                  */
/*  DATE WRITTEN - 07/15/02                                         */
/*  WRITTEN BY   - D.BEECH                                          */
/*                                                                  */
/********************************************************************/

             PGM        PARM(&FULLOBJ &TYPE &MBR &DELAY &PASS)
             DCL        VAR(&FULLOBJ)   TYPE(*CHAR) LEN(20)
             DCL        VAR(&OBJ)       TYPE(*CHAR) LEN(10)
             DCL        VAR(&LIBL)      TYPE(*CHAR) LEN(10)
             DCL        VAR(&TYPE)      TYPE(*CHAR) LEN(07)
             DCL        VAR(&MBR)       TYPE(*CHAR) LEN(10)
             DCL        VAR(&DELAY)     TYPE(*CHAR) LEN(03)
             DCL        VAR(&PASS)      TYPE(*CHAR) LEN(01)
             DCL        VAR(&DLY)       TYPE(*DEC)  LEN(3 0)
             DCL        VAR(&MSG)       TYPE(*CHAR) LEN(117)
             DCLF       FILE(CUPLCK1)
             CHGVAR     VAR(&OBJ)  VALUE(%SST(&FULLOBJ 1 10))
             CHGVAR     VAR(&LIBL) VALUE(%SST(&FULLOBJ 11 10))
             CHGVAR     VAR(&MSG)  VALUE('The files that you are +
                          accessing may delay a critical MIS job +
                          from running. Please sign off the system +
                          in     seconds')
             CHGVAR     VAR(%SST(&MSG 107 3)) VALUE(&DELAY)
             CHGVAR     VAR(&DLY)  VALUE(&DELAY)
/********************************************************************/
/* READS CUPLCK1 FILE OF DEVICE/USER/NUMBER RECORDS                 */
/********************************************************************/
             OPNDBF     FILE(CUPLCK1) OPTION(*INP)
     READ1:  RCVF
             MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(NEXT))
             DSPJOB     JOB(&DSPNBR/&DSPUSR/&DSPDEV) OUTPUT(*PRINT)
             MONMSG     MSGID(CPF0941 CPF0001 CPD0085) EXEC(GOTO +
                          CMDLBL(READ1))
             DLTSPLF    FILE(QPDSPJOB)
             MONMSG     MSGID(CPF3309 CPF0001 CPD0085) EXEC(GOTO +
                          CMDLBL(READ1))
/********************************************************************/
/* ON PASS = 1 SEND A BREAK MESSAGE TO USER THAT SESSION WILL BE    */
/* ENDED IN 30-900 SECONDS                                          */
/********************************************************************/
             IF         COND(&PASS *EQ '1') THEN(DO)
             SNDBRKMSG  MSG(&MSG) TOMSGQ(&DSPDEV)
             ENDDO
/********************************************************************/
/* ON PASS = 1 SEND A BREAK MESSAGE TO USER                         */
/********************************************************************/
             IF         COND(&PASS *EQ '2') THEN(DO)
             ENDJOB     JOB(&DSPNBR/&DSPUSR/&DSPDEV) OPTION(*IMMED) +
                          DELAY(&DELAY)
             ENDDO
/********************************************************************/
/* LOOP TO READ THROUGH CUPLCK1 FILE                                */
/********************************************************************/
             GOTO CMDLBL(READ1)
/********************************************************************/
/* CLOSE FILE CUPLCK1                                               */
/********************************************************************/
      NEXT:  CLOF       OPNID(CUPLCK1)
/********************************************************************/
/* DELAY IF PASS = 1 TO GIVE USERS TIME TO SIGNOFF                  */
/********************************************************************/
             IF         COND(&PASS *EQ '1') THEN(DO)
             DLYJOB     DLY(&DLY)
             ENDDO
      EXIT:  ENDPGM

Dig Deeper on iSeries programming commands

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close