Sending Messages

DC provides message management functions that allow you to send messages to the following destinations:
idmscu19
DC provides message management functions that allow you to send messages to the following destinations:
  • The log file and the current user, optionally terminating the program
  • Other users, logical terminals, or destinations
Sending messages to the current user and to other users is discussed below.
This article describes the following information:
2
2
Sending a Message to the Current User
You can send a message predefined in the DDLDCMSG area of the dictionary to the current user, the log file, or both. The message definition can also specify other destinations (for example, the user's console). Additionally, the specified message indicates the action to be taken after the message is written; such action can include the following:
  • Waiting for user reply
    -DC does not return control to your task until it receives a reply from the user's console.
  • Abending the program
    -DC abends your program, or, optionally, the DC system.
  • Continuing program execution
    -DC returns control to your program, optionally writing a snap dump of specified resources.
Retrieving Predefined Messages
One typical use for dictionary-defined messages is to retrieve predefined messages from the DDLDCMSG area rather than include all possible messages in program variable storage.
Messages stored in the dictionary can contain symbolic parameters. Symbolic parameters, identified by an ampersand (&). followed by a two-digit number, can appear in any order within the message. Symbolic parameters provide flexibility in message management.
Steps to Send a Predefined Message
To send a predefined message, perform the following steps:
  1. If you are using symbolic parameters, initialize the appropriate variable-storage locations.
  2. Issue a WRITE LOG statement that specifies the appropriate variable-storage locations for symbolic parameters, user reply, and message text.
You can specify your own message prefix (to distinguish your messages from DC/UCF system messages) by using the MESSAGE PREFIX IS parameter on the WRITE LOG statement.
Example of Sending a Message from the Dictionary
The program excerpt below uses the following message from the DDLDCMSG area of the dictionary:
INPUT DATA IS IN ERROR; DATA FIELD: &01.  &02.  
The symbolic parameters allow you to transmit more meaningful messages.
 DATA DIVISION.  WORKING-STORAGE SECTION.  01  SYMBOLIC-PARAMETERS.    03 ERR-1.      05 ERR-1-TEXT              PIC X(15).      05 ERR-1-END               PIC X.    03 ERR-2.      05 ERR-2-TEXT              PIC X(15).      05 ERR-2-END               PIC X.    03 ERR-DEPT-ID               PIC X(6)    VALUE 'DEPT-ID'    03 ERR-NONNUMERIC            PIC X(10)   VALUE 'NONNUMERIC'.  01  MESSAGES.      05 MESSAGE-AREA.           PIC X(80).      05 MESSAGE-AREA-END        PIC X.  PROCEDURE DIVISION.      BIND MAP SOLICIT.      BIND MAP SOLICIT RECORD SOLICIT-REC. *      MAP IN USING SOLICIT. *** IF ERROR, INITIALIZE FIELDS FOR SYMBOLIC PARMS ***      IF SOLICIT-DEPT-ID NOT NUMERIC         THEN MOVE ERR-DEPT-ID TO ERR-TEXT-1              MOVE ERR-NONNUMERIC TO ERR-TEXT-2              GO TO SOLICIT-ERROR.         .         .  SOLICIT-ERROR. *** USE WRITE LOG STATEMENT TO COPY *** *** DICTIONARY MESSAGE WITH PARMS INTO *** *** PROGRAM VARIABLE STORAGE ***      WRITE LOG MESSAGE ID 9001080         PARMS FROM ERR-1 TO ERR-1-END         FROM ERR-2 TO ERR-2-END         TEXT INTO MESSAGE-AREA TO MESSAGE-AREA-END         TEXT IS ONLY. *** MAP OUT USING MESSAGE FROM DATA DICTIONARY ***      MAP OUT USING SOLICIT         MESSAGE IS MESSAGE-AREA TO MESSAGE-AREA-END.      DC RETURN         NEXT TASK CODE 'DEPTDIS'.
Sending a Message to Other Users
DC provides the facilities for you to send messages to another terminal or user or to a group of terminals or users defined as a destination during system generation.
To send a message to another user, perform the following steps:
  1. Initialize the variable-storage location from which the message is to be sent.
  2. Issue a SEND MESSAGE statement that specifies the message's destination.
To conserve resources, it is best not to specify the ALWAYS parameter in conjunction with a group of users.
Example of Sending a Message to Another User
The program below is called by other programs in order to send a message to a specified user.
 DATA DIVISION.  WORKING-STORAGE SECTION.  LINKAGE SECTION.  01  MESS-INFO.      05 MESS-USER-ID            PIC X(32).      05 MESS-TEXT               PIC X(79).      05 MESS-TEXT-END           PIC X.      05 MESS-INFO-END           PIC X.  PROCEDURE DIVISION. *** ESTABLISH ADDRESSABILITY TO USER ID AND MESSAGE TEXT ***      GET STORAGE  FOR MESS-INFO TO MESS-INFO-END          KEEP SHORT USER STGID 'MSG1'          ON DC-NEW-STORAGE NEXT SENTENCE. *** SEND MESSAGE TO SPECIFIED USER ID ***      SEND MESSAGE ONLY TO USER ID MESS-USER-ID         FROM MESS-TEXT TO MESS-TEXT-END. *      FREE STORAGE STGID 'MSG1'.      DC RETURN.