Using default HZSMGB data area format (MGBFORMAT=0)

Figure 1 shows an example of how you define the message variables in your check routine:

 1  shows an example of defining the message number in the MGB_MessageNumber.

 2  shows an example of filling in the MGB_InsertCnt field with the number of variables for your message.

 3  shows an example of putting the address of one variable into the MGB_Inserts field. This address points to the area in storage where the length and value of the variable are defined, mapped by MGB_InsertD.

 4  shows an example of defining the length and value of the variable in the MGB_MsgILen and MGB_MsgIVal fields for the variable in storage. These fields are in the MGB_InsertD mapping.

 5  shows an example of issuing a message. Note that this example shows a local message. For a remote check, the HZSFMSG macro must include the REMOTE=YES, HANDLE=handle, and MSGTABLE=msgtable parameters.

 6  shows how the variable address, length, and value are defined to be stored in the HZSMGB data area or in storage.

 7  shows an example of creating an area big enough in the HZSMGB for the information about all your variables. To create enough room for all your variables, use the formula HZSMGB_LEN + (n-1)*L'MGB_inserts where n is the number of inserts. HZSMGB_LEN by itself will provide room for only one insert.

Figure 1 shows check routine code that defines variable data in the HZSMGB:
Figure 1. Example of issuing a message with variables in an assembler check
*************************************************************  
* Issue a message with two inserts                          *  
*************************************************************  
         SYSSTATE ARCHLVL=1                                    
* save regs, get dynamic storage, chain saveareas, set usings  
         LA    2,TheMGBArea                                    
         ST    2,TheMGBAddr                                    
         USING HZSMGB,2                                        
        1   MVC   MGB_MessageNumber,=F'1' Message 1     
        2   MVC   MGB_insert_cnt,=F'2'  Two inserts
         LA    3,Insert1Area         Address of first insert  
        3   ST    3,MGB_Inserts         Save insert address       
         LA    3,Insert2Area         Address of second insert  
         USING MGB_MsgInsertD,3                                
        4   MVC   MGB_MsgILen,=AL2(L'Insert2Val)  Insert length   
         MVC   MGB_MsgIVal(L'Insert2Val),MyMod Insert value    
         DROP  3                                               
         ST    3,MGB_Inserts+4       Save insert address       
        5   HZSFMSG  REQUEST=CHECKMSG,MGBADDR=TheMGBAddr,       * 
               RETCODE=LRETCODE,RSNCODE=LRSNCODE,            * 
               MF=(E,FMSGL)                                   
         DROP  2                                               
*                                                              
* Place code to check return/reason codes here                 
*                                                              
* free dynamic storage, restore regs          
         BR 14 
MyMod    DC   CL8'MYMODULE'  6                           
* Area for first insert                               
Insert1Area DS 0H                                     
Insert1Len  DC AL2(L'Insert1Val)                      
Insert1Val  DC C'CSA   '            
         LTORG ,                                      
         HZSZCONS ,            Return code information
         HZSMGB   ,            Insert mapping         
DYNAREA  DSECT                                        
LRETCODE DS   F                                       
LRSNCODE DS   F                                       
* Area for 2 inserts (HZSMGB_LEN accounts for one, so 
* we add one more "length of MGB_Inserts")            
TheMGBAddr DS A   7                                      
TheMGBArea DS CL(HZSMGB_LEN+1*L'MGB_Inserts)          
* Area for second insert                              
Insert2Area DS 0H                                     
Insert2Len  DS AL2(L'Insert2Val)            
Insert2Val  DC X'00950000'                            
         HZSFMSG MF=(L,FMSGL),PLISTVER=MAX            
DYNAREA_LEN EQU *-DYNAREA  
      

Important fields in the HZSMGB data area include:

Table 1. Important MGBFORMAT=0 fields in the HZSMGB data area for check message variables
Field name Meaning

MGB_MessageNumber
MGB_ID

Fullword field containing the value identifying each message. These fields are the same - there are two names for this field. This field corresponds to the xreftext value for each message. For example, the xreftext value for a message is coded as follows:
<msgnum xreftext="001">TESTMSG1I</msgnum>
MGB_InsertCnt Fullword field containing the number of variables (or inserts) to follow.

MGB_Inserts
MGB_InsertAddr

These fields are the same - there are two names for this field.

This field contains an array of pointers, each of which contains the address in storage of an area for a specific variable. This area is mapped by Mgb_MsgInsertD.

MGB_MsgInsertD A structure in the HZSMGB data area that describes the length and value of the variable:
  • MGB_MsgILen, which is a 2 byte field containing the length of the variable.
  • MGB_MsgIVal, which contains the value of the variable.