Ü    SNDPGMMSG  

 

·         This command is used to send impromptu message (messages i.e. not predefined) or predefined messages to the user/system operator.

·         It can be used in CL program but cannot be used on command line directly.

·         The format of this command for impromptu message is:

SNDPGMMSG  MSG(‘message text’)
           TOUSR(user name/*SYSOPR/*REQUESTER)       
           TOMSGQ(user queue name/*/*SYSOPR/*EXT)
           TOPGMQ(program queue name)  
           MSGTYPE(*INFO/*INQ)
           VALUES(list of allowable replies)
           DFT(default reply value)
           MSGRPY(message reply)    

 

·         The format of this command for predefined message is:

SNDPGMMSG  MSGID(message id)
           MSGF(message file name)
           TOUSR(user name/*SYSOPR/*REQUESTER)       
           TOMSGQ(user queue name/*/*SYSOPR/*EXT)
           TOPGMQ(program queue name)  
           MSGTYPE(*INFO/*INQ)
           VALUES(list of allowable replies)
           DFT(default reply value)
           MSGRPY(message reply)    

 

·         The format of this command for predefined message with message data (MSGDTA) option is:

SNDPGMMSG  MSGID(message id)
           MSGF(message file name)
           MSGDTA(&messge_data)   
           TOUSR(user name/*SYSOPR/*REQUESTER)       
           TOMSGQ(user queue name/*/*SYSOPR/*EXT)
           TOPGMQ(program queue name)  
           MSGTYPE(*INFO/*INQ)
           VALUES(list of allowable replies)
           DFT(default reply value)
           MSGRPY(message reply)    

 

·         TOUSR and TOMSGQ parameter is mutually exclusive. Only one should be mentioned at a time.

·         If TOUSR=*SYSOPR, then the message is sent to the system operator.

·         If TOUSR=*REQUESTER, then the message is sent to the user who is running the interactive job or to QSYSOPR.

·         If TOMSGQ=*, then the message is sent to external message queue for interactive job and is sent to the system operator for batch job.

·         If TOMSGQ=*EXT, then the message is sent to external message queue.

·         TOPGMQ is used to send the message to the caller level in the call stack. It’s value can be *SAME, *PRV, *EXT.

Suppose we have program PGM001 calling program PGM002.

Now the call stack entry for this will be like:

PGM002

PGM001

QCMD 

 

            Now suppose PGM002 has the SNDPGMMSG command as below:

     CASE(1): SNDPGMMSG   TOPGMQ(*SAME)

                             The message is sent to the same program PGM002.

            CASE(2): SNDPGMMSG   TOPGMQ(*PRV)

                             The message is sent to the previous program PGM001.

            CASE(3): SNDPGMMSG   TOPGMQ(*SAME  PGM001)

                             The message is sent to the program same as PGM001 i.e. to PGM001.

            CASE(4): SNDPGMMSG   TOPGMQ(*PRV   PGM001)

                             The message is sent to the program previous to PGM001 i.e. to QCMD.

 

§  MSGTYPE can be *INFO, *INQ, *RQS, *COMP, *DIAG, *NOTIFY, *ESCAPE or *STATUS.

·         In case of predefined messages if we are using message data(MSGDTA) then the message data will replace the substitution variable inside the message. Substitution variable is given at the time any message is defined.

e.g. Defining the MSGDTA substitution variable

 
===> ADDMSGD MSGID(ID00004) 
             MSGF(IROBO1/MSGF001) 
             MSG('THE RECORD COUNT HAS BEEN DONE &1 TIMES') 
             FMT((*CHAR 1))

 

Example:


Columns . . . :    1 100             Edit                        IROBO1/QRPGLESRC
 SEU==>                                                                MONMSG_CL1
FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7  
       ********************* Beginning of data *********************************
0001.00 PGM
0002.00     DCLF       FILE(ACCOUNT) OPNID(ID1)
0003.00     DCL        VAR(&COUNT) TYPE(*DEC) LEN(2) VALUE(0)
0004.00     DCL        VAR(&CHAR) TYPE(*CHAR) LEN(2) VALUE(' ')
0005.00     DCL        VAR(&DSP) TYPE(*CHAR) LEN(35) VALUE(' ')
0006.00     DCL        VAR(&REPLY) TYPE(*CHAR) LEN(01) VALUE('N')
0007.00     MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))
0008.00
0009.00     ADDLIBLE   IROBO1
0010.00     MONMSG     MSGID(CPF2103)
0011.00     /*IF THE ERROR COMES WE DON'T DO ANYTHING AND LET THE PGM CONTINUE*/
0012.00
0013.00     CHKOBJ     OBJ(*LIBL/ACCOUNT) OBJTYPE(*FILE) MBR(*FIRST)
0014.00     MONMSG     MSGID(CPF9801) EXEC(GOTO CMDLBL(ERROR))
0015.00
0016.00     /* READ THE FILE AND TAKE THE RECORD COUNT*/
0017.00     READ:
0018.00     RCVF       OPNID(ID1)
0019.00     MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END))
0019.00     MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END))
0020.00     CHGVAR     VAR(&COUNT) VALUE(&COUNT+1)
0021.00     CHGVAR     VAR(&CHAR) VALUE(&COUNT)
0022.00     SNDUSRMSG  MSG('DO U WANT TO PROCEED, TYPE(Y/N)') +
0023.00                MSGTYPE(*INQ) MSGRPY(&REPLY)
0024.00     IF         COND(&REPLY = 'Y') THEN(GOTO CMDLBL(READ))
0025.00     ELSE       CMD(GOTO CMDLBL(END))
0026.00
0027.00 ERROR:
0028.00              SNDPGMMSG   MSG('THERE IS SOME ERROR, CHECK THE PROGRAM')
0029.00
0030.00 END:
0031.00              CLOF       OPNID(ID1)
0032.00              MONMSG     MSGID(CPF4520)
0033.00              CHGVAR     VAR(&DSP) VALUE('TOTAL RECORD COUNT IS  ' +
0034.00                           *CAT &CHAR)
0035.00              SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&DSP)
0036.00              SNDPGMMSG  MSGID(ID00004) MSGF(MSGF001) MSGDTA(&CHAR)
0037.00
0038.00 ENDPGM
        ****************** End of data ****************************************




Where, ID00004 has been defined as below.

 

                                                             System:   PUB1
 Message ID . . . . . . . . . :   ID00004                                  
 Message file . . . . . . . . :   MSGF001                                  
   Library  . . . . . . . . . :     IROBO1                                 
 Message text . . . . . . . . :   THE RECORD COUNT HAS BEEN DONE &1 TIMES  
                                                                           
                                     Decimal       Vary          
 Field     Data Type     Length     Positions     Length     Dump
  &1       *CHAR             2                               *NO 

 

 

 

OUTPUT

 


                           Display Program Messages                            
                                                                               
 DO U WANT TO PROCEED, TYPE(Y/N)                                               
 Y                                                                             
 DO U WANT TO PROCEED, TYPE(Y/N)                                               
 Y                                                                             
 DO U WANT TO PROCEED, TYPE(Y/N)                                               
 Y                                                                             
 DO U WANT TO PROCEED, TYPE(Y/N)                                               
                                                                                
 Type reply, press Enter.                                                      
 Reply . . .   N                                  
 ____________________________________________________
                                                                               
 F3=Exit   F12=Cancel                                                           

 

 

 

 

 


                           Work with Members Using PDM                 PUB1    
                                                                                
 File  . . . . . .   QRPGLESRC                                                 
   Library . . . .     IROBO1               Position to  . . . . .             
                                                                                
 Type options, press Enter.                                                    
  2=Edit         3=Copy  4=Delete 5=Display       6=Print     7=Rename         
  8=Display description  9=Save  13=Change text  14=Compile  15=Create module...
                                                                               
 Opt  Member      Type        Text                                             
      MONMSG_CL1  CLP         MONMSG DEMOSTRATION                              
 
 
 
                                                                        More...
 Parameters or command                                                         
 ===>                                                                          
 F3=Exit          F4=Prompt             F5=Refresh            F6=Create        
 F9=Retrieve      F10=Command entry     F23=More options      F24=More keys    
 TOTAL RECORD COUNT IS  04.                                                   +
 THE RECORD COUNT HAS BEEN DONE 04 TIMES

 

 

 



 

 







User Comments:



Subscribe

  Email:



Copyright © www.go4as400.com, 2013-2017. Copyright notice