Example 2

Operation:
  • Same as example 1, but using MGBFORMAT=1 and the MGB parameter rather than the MGBADDR parameter.
The code is as follows.
************************************************************* 
* Issue a message with two inserts, MGBFORMAT=1.            *
* For MGBFORMAT=0, it was necessary to move the insert      *
* data if it was not in the form of a halfword length       *
* followed by the data.                                     *
* For MGBFORMAT=1, that is not necessary since the length   *
* is specified in the MGB_MsgInsertDesc DSECT.              *
*************************************************************
         SYSSTATE ARCHLVL=1
* save regs, get dynamic storage, chain saveareas, set usings
* somewhere there needs to be code to set Insert2Val
         LA    2,TheMGB1Area
         USING HZSMGB1,2
         MVC   MGB1_MessageNumber,=F'1' Message 1
         MVC   MGB1_insert_cnt,=F'2' Two inserts
* address first insert description
         LA    3,MGB1_insert_structure_Entries
         USING MGB1_MsgInsertDesc,3
* fill in first insert description
         LA    4,L'Insert1Val
         ST    4,MGB1_MsgInsertDesc_Length
         LA    4,Insert1Val
         ST    4,MGB1_MsgInsertDesc_Addr
* move on to next insert description
         LA    3,MGB1_insert_structure_Entries_Len(,3)
* fill in second insert description
         LA    4,L'Insert2Val
         ST    4,MGB1_MsgInsertDesc_Length
         MVC   Insert2Val(L'Insert2Val),MyMod Insert value
         LA    4,Insert2Val
         ST    4,MGB1_MsgInsertDesc_Addr
         DROP  3
         HZSFMSG  REQUEST=CHECKMSG,MGB=TheMGB1Area,          *
               RETCODE=LRETCODE,RSNCODE=LRSNCODE,            *
               MGBFORMAT=1,MF=(E,FMSGL)
         DROP  2
*
* Place code to check return/reason codes here
*
* free dynamic storage, restore regs
         BR   14
MyMod    DC   CL8'MYMODULE'
* Area for first insert
Insert1Val  DC C'This is a static insert'
         LTORG ,
         HZSZCONS ,            Return code information
         HZSMGB   ,            Insert mapping
DYNAREA  DSECT
LRETCODE DS   F
LRSNCODE DS   F
* Area for 2 inserts (HZSMGB1_LEN accounts for none,
* we add two "length of MGB1_MsgInsertDesc"
           DS 0F
TheMGB1Area DS CL(HZSMGB1_LEN+1*L'MGB1_Inserts)
* Area for second insert
Insert2Val  DS CL(L'MyMod)
         HZSFMSG MF=(L,FMSGL),PLISTVER=MAX
DYNAREA_LEN EQU *-DYNAREA