MSGID keyword

You use this field-level keyword to allow an application program to identify, at program run time, the message description that contains text for a named field.

You can specify the MSGID keyword in either of the following formats:
MSGID(message-identifier [library-name/]message-file)
MSGID(*NONE)

You can specify the message-file parameter in one of the following forms:

  • &field3

    where the field3 length is two (2).

    The field name must exist in the same record as the MSGID field, and the field must be defined as a character field with usage H, P, B, or O.

    You should, for this form only, specify only special values for the file parameter. You cannot specify a library.

    The special values are: U1, U2, P1, P2, M1, and M2. If the specified value is not one of these special values, U1 is used. See Table 1 for more information about these values.

  • Special values for message-file:
    • *USR1
    • *USR2
    • *PGM1
    • *PGM2
    • *SYS1
    • *SYS2

    When you code a special value for the message-file, the library parameter is not allowed and the library is set to *LIBL as default. See Table 1 for more information about these special values.

The following table describes the meaning of the special file values for the MSGID keyword.

Table 1. Special values on MSGID keyword
DDS special value Length 2 field value Message text retrieved
*USR1 U1 First level text from message file USR1
*USR2 U2 Second level text from message file USR2
*PGM1 P1 First level text from message file PGM1
*PGM2 P2 Second level text from message file PGM2
*SYS1 M1 First level text from message file SYS1
*SYS2 M2 Second level text from message file SYS2

For information about using message retrieval, see the Application Display Programming bookLink to PDF.

The *NONE parameter indicates that no message text is displayed.

The following example shows how to specify the MSGID keyword.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R RECORD1
     A            MSGFIELD1     40A  B 02 10MSGID(CPD0001 *USR1)
     A            MSGFIELD2     10A  O 02 60MSGID(&MSGIDNUM &MSGFILENM);
     A            MSGFIELD3     80A  B 02 60
     A  99                                  MSGID(USR &MSGNBR +
     A                                      &MSGFILENM);
     A                                      MSGID(*NONE)
     A            MSGIDNUM       7A  P      TEXT('Message id')
     A            MSGFILENM      2A  P      TEXT('Message file name')
     A            MSGNBR         4A  P 07 01TEXT('Message number')
     A

When RECORD1 is displayed:

  • MSGFIELD1 contains the first 40 characters of the message CPD0001 from the message file USR1. Because the field is input/output (usage B), the value of the field can be changed by the user.
  • MSGFIELD2 contains the first 10 characters of the message identified by the fields MSGIDNUM and MSGFILENM. Values for MSGIDNUM (the message identifier) and MSGFILENM (the message file) must be set in the program before the display of RECORD1. Because MSGFIELD2 is an output-only field (usage O), it cannot be used in the program.
  • If option indicator 99 is on, MSGFIELD3 contains the first 80 characters of the message identified by the prefix USR, the message number set in field MSGNBR, and the message file set in field MSGFILENM. If option indicator 99 is off, MSGFIELD3 does not contain any message text.