contact image



Message subfile Example


Download Programs/Display in text


Message subfiles are special subfiles designed to hold--you guessed it--messages.
Message subfiles have some unique properties that make them very useful.
They load themselves automatically from messages on a given program message queue.
Message subfiles also allow users to view the second-level help text associated
with a message, without any additional programming effort. Message subfiles
make it possible to setup a consistent set of information, warning, or error
messages in a message file for a given program or application, and to display those
messages to the user with the greatest of ease.



Add the below section to your DDS...

*=========================================================================
      * Message subfile stuff.
      *=========================================================================
     A          R MSGSFL                    SFL
     A                                      SFLMSGRCD(24)
     A            MSGKEY                    SFLMSGKEY
     A            PGMQ                      SFLPGMQ(10)
      *=========================================================================
      * Message subfile stuff
      *=========================================================================
     A          R MSGCTL                    SFLCTL(MSGSFL)
     A                                      SFLDSP
     A                                      SFLDSPCTL
     A                                      SFLINZ
     A N03                                  SFLEND
     A                                      SFLSIZ(0002)
     A                                      SFLPAG(0001)
     A            PGMQ                      SFLPGMQ(10)


Now the RPG... You must add a bit more here.
 
      *
      * formational data structure  Message subfile
      *
     D                 DS                        INZ
     D STKCNT                001    004B 0
     D DTALEN                005    008B 0
     D ERRCOD                009    012B 0
	 
	 
* * Initialize the message subfile fields * c Movel 'LBIMSGF' MSGF 20 c Movel '*LIBL' MSGLIB 10 c Move MSGLIB MSGF c Move *blanks MSGKY 04 c Move *blanks MSGDTA 80 c Movel '*DIAG' MSGTYP 10 c Movel '*ALL' MSGRMV 10 c Movel *blanks MSGID 07 * c Movel(p) @PGM PGMQ c Z-Add 60. DTALEN
c Write MSGCTL 99
c Exsr $CLRMSG
and the API ’s to send and clear the messages *==============================================================-============= * $SndMsg - Send a message to the message subfile *========================================================================= c $SndMsg Begsr * c call 'QMHSNDPM' c parm MSGID c parm MSGF c parm MSGDTA c parm DTALEN c parm MSGTYP c parm PGMQ c parm STKCNT c parm MSGKEY c Parm ERRCOD * c endsr *========================================================================= * $ClrMsg - Clear the messages from the screen *========================================================================= c $ClrMsg Begsr * c call 'QMHRMVPM' c parm PGMQ c parm STKCNT c parm MSGKY c parm MSGRMV c parm ERRCOD * c endsr


I have also included a CL program that will create the message file and the messages used for this example.
 
 pgm
monmsg cpf0000
 
             CRTMSGF    MSGF(QGPL/LBIMSGF)
 
             ADDMSGD    MSGID(GEN0001) MSGF(LBIMSGF) MSG('Please +
                          make selections, press  to co +
                          ntinue.') SEV(10)
 
             ADDMSGD    MSGID(TST0001) MSGF(LBIMSGF) MSG('The data +
                          entered &1 must be of a length of six') +
                          SEV(20) FMT((*CHAR 10))
 
             ADDMSGD    MSGID(TST0002) MSGF(LBIMSGF) MSG('Value &1 +
                          entered is invalid. Please enter A , E, +
                          or F.') SEV(20) FMT((*CHAR 1))
 
             ADDMSGD    MSGID(TST0003) MSGF(LBIMSGF) MSG('Value &1 +
                          when added to &2 does not equal 30.') +
                          SEV(20) FMT((*CHAR 2) (*CHAR 2))
 
exit:
endpgm