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

CPYMSGDCLP

CPYMSGDCLP

CPYMSGDCLP
 
/********************************************************************/
/*       PROGRAM NAME:   CPYMSGDCLP                                 */
/*       DATE WRITTEN:   10/26/2001                                 */
/*       AUTHOR......:   Vijayakumar kannan                         */
/*       FUNCTION....:   This is used to copy message description   */
/*                       from one lpar to another lpar              */
/*                                                                  */
/********************************************************************/
             PGM        PARM(&MSGID &MSGF &MSGFLIB &FTXT &STXT +
                          &SEVNUM &FMT &No_LPARS &LPARS)

  /* define incoming parms */
             DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)
             DCL        VAR(&MSGF) TYPE(*CHAR) LEN(10)
             DCL        VAR(&MSGFLIB) TYPE(*CHAR) LEN(10)
             DCL        VAR(&FTXT) TYPE(*CHAR) LEN(132)
             DCL        VAR(&FTXT1) TYPE(*CHAR) LEN(132)
             DCL        VAR(&STXT) TYPE(*CHAR) LEN(3000)
             DCL        VAR(&STXT1) TYPE(*CHAR) LEN(3000)
             DCL        VAR(&SEVNUM) TYPE(*DEC) LEN(2 0)
             DCL        VAR(&FMT) TYPE(*CHAR) LEN(1000)
             DCL        VAR(&No_LPARS) TYPE(*DEC) LEN(2 0)
             DCL        VAR(&LPARS) TYPE(*CHAR) LEN(40)

  /* define variables required to create DDM files */
             DCL        VAR(&DDMF) TYPE(*CHAR) LEN(10)
             DCL        VAR(&DDMLIB) TYPE(*CHAR) LEN(10)
             DCL        VAR(&RMTLOC) TYPE(*CHAR) LEN(10)
             DCL        VAR(&CMD) TYPE(*CHAR) LEN(400)

  /* define variables required for message handling */
             DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(70)
             DCL        VAR(&MSGKEY) TYPE(*CHAR) LEN(4)
             DCL        VAR(&MSG) TYPE(*CHAR) LEN(100)
             DCL        VAR(&SEV) TYPE(*DEC) LEN(2 0)
             DCL        VAR(&ERRORFLAG) TYPE(*LGL) LEN(1)
             DCL        VAR(&PRVCALLER) TYPE(*CHAR) LEN(10) +
                          VALUE('CPYMSGDRPG')

  /* define other working variables */
             DCL        VAR(&SEVCHAR) TYPE(*CHAR) LEN(2)
             DCL        VAR(&CUR_LPAR) TYPE(*DEC) LEN(2 0)
             DCL        VAR(&CUR_SYS) TYPE(*CHAR) LEN(2)
             DCL        VAR(&START) TYPE(*DEC) LEN(2 0)
             DCL        VAR(&HOST) TYPE(*CHAR) LEN(8)

      /* Global message monitor to trap any unmonitored errors */

             MONMSG     (CPF9999 CPF0000 MCH0000) EXEC(GOTO ERROR)

      /* get the host system name */
             RTVNETA    SYSNAME(&HOST)

      /*  CONVERT SEVERITY FROM NUMERIC TO ALPHA */

             CHGVAR     VAR(&SEVCHAR) VALUE(&SEVNUM)

      /*  enclose the messages in single quotes */

             CHGVAR     VAR(&FTXT) VALUE('''' *TCAT &FTXT *TCAT '''')
             CHGVAR     VAR(&FTXT1) VALUE(&FTXT)
             CHGVAR     VAR(&STXT) VALUE('''' *TCAT &STXT *TCAT '''')
             CHGVAR     VAR(&STXT1) VALUE(&STXT)


      /*  enclose the messages in double quotes */

             CHGVAR     VAR(&FTXT) VALUE('''' *TCAT &FTXT *TCAT '''')
             CHGVAR     VAR(&STXT) VALUE('''' *TCAT &STXT *TCAT '''')

      /*  ADD the message to other systems if  requested */

             CHGVAR     VAR(&START) VALUE(1)
             CHGVAR     VAR(&DDMLIB) VALUE('QTEMP')

     /* Loop thru until messages are added across all systems */

Loop:
             chgvar     var(&RMTLOC) value(%sst(&lpars &start 10))
             chgvar     var(&cur_sys) value(&cur_lpar)
             chgvar     var(&DDMF) value('DDMF' *CAT &cur_sys)

             IF         COND(&cur_lpar *LT &No_lpars) THEN(DO)

      /*  ADD the message to current system from where this */
      /*  command is executed */
             IF         COND(&RMTLOC *eq &host) then(DO)

             CHGVAR     VAR(&CMD) VALUE('ADDMSGD MSGID(' *TCAT +
                          &MSGID *TCAT ')' *BCAT 'MSGF(' *TCAT +
                          &MSGFLIB *TCAT '/' *TCAT &MSGF *TCAT ')' +
                          *BCAT 'MSG(' *TCAT &FTXT1 *TCAT ')' *BCAT +
                          'SECLVL(' *TCAT &STXT1 *TCAT ')' *BCAT +
                          'SEV(' *TCAT &SEVCHAR *TCAT ')' *BCAT +
                          'FMT(' *TCAT &FMT *TCAT ')')
             ENDDO
             ELSE       CMD(DO)
             CRTDDMF    FILE(&DDMLIB/&DDMF) RMTFILE(&DDMLIB/&DDMF) +
                          RMTLOCNAME(&RMTLOC)
             MONMSG     MSGID(CPF0000 CPF9999)

             CHGVAR     VAR(&CMD) VALUE('SBMRMTCMD CMD(' *TCAT '''' +
                          *TCAT 'ADDMSGD MSGID(' *TCAT &MSGID *TCAT +
                          ')' *BCAT 'MSGF(' *TCAT &MSGFLIB *TCAT +
                          '/' *TCAT &MSGF *TCAT ')' *BCAT 'MSG(' +
                          *TCAT &FTXT *TCAT ')' *BCAT 'SECLVL(' +
                          *TCAT &STXT *TCAT ')' *BCAT 'SEV(' *TCAT +
                          &SEVCHAR *TCAT ')' *BCAT 'FMT(' *TCAT +
                          &FMT *TCAT ')' *TCAT '''' *TCAT ')' *BCAT +
                          'DDMFILE(' *TCAT &DDMLIB *TCAT '/' *CAT +
                          &DDMF *TCAT ')')
             ENDDO
             CALL       PGM(QCMDEXC) PARM(&CMD 400)

/* set the offset to point to next system name */

             CHGVAR     VAR(&CUR_LPAR) VALUE(&CUR_LPAR + 1)
             CHGVAR     VAR(&START) VALUE(&START + 10)

/* delete the temporary ddmfile */

             DLTF       FILE(&DDMLIB/&DDMF)
             MONMSG     MSGID(CPF0000 CPF9999)

             GOTO       CMDLBL(LOOP)
             ENDDO

             GOTO       CMDLBL(ENDPGM)
/*-------------------------------------------------------------------*/
/* Global Error Handling Routine                                     */
/*-------------------------------------------------------------------*/
ERROR:

/* If looping in the error handling routine, end in error            */
/*                                                                   */
             IF         (&ErrorFlag) DO
             SNDPGMMSG  MSGID(CPF9999) MSGF(QCPFMSG) TOPGMQ(*PRV +
                          (&PRVCALLER)) MSGTYPE(*ESCAPE)
                 MONMSG     CPF0000
                 GOTO       ENDPGM
             ENDDO

/* Set flag to prevent looping                                       */
/*                                                                   */
             CHGVAR     &ErrorFlag '1'

/* capture any diagnostic messages sent to this program and  resend  */
/* the same as a status message                                      */

ERROR1:     RCVMSG     MSGTYPE(*DIAG)                               +
                        RMV(*NO)                                     +
                        KEYVAR(&MsgKey)                              +
                        MSG(&Msg)                                    +
                        MSGDTA(&MsgDta)                              +
                        MSGID(&MsgID)                                +
                        MSGF(&Msgf)                                  +
                        SNDMSGFLIB(&MsgFLib)
             IF         (&MsgKey *EQ ' ') (GOTO ERROR2)
             RMVMSG     MSGKEY(&MsgKey)
             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
                          MSGDTA(&MSGDTA) TOPGMQ(*PRV (&PRVCALLER)) +
                          MSGTYPE(*DIAG)
             GOTO       CMDLBL(ERROR1)

/* Capture any escape messages sent to this program by the system   */

ERROR2:     RCVMSG     MSGTYPE(*EXCP)                               +
                        RMV(*NO)                                     +
                        MSG(&Msg)                                    +
                        MSGDTA(&MsgDta)                              +
                        MSGID(&MsgID)                                +
                        SEV(&Sev)                                    +
                        MSGF(&Msgf)                                  +
                        SNDMSGFLIB(&MsgFLib)
             IF         (&Sev *gt 00) THEN(DO)
             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
                          MSGDTA(&MSGDTA) TOPGMQ(*PRV (&PRVCALLER)) +
                          MSGTYPE(*ESCAPE)
             ENDDO
             ELSE       DO
             SNDPGMMSG  MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(&MSG) +
                          TOPGMQ(*PRV (&PRVCALLER)) MSGTYPE(*ESCAPE)
             ENDDO
ENDPGM:     RETURN
             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