Previous Topic: Sending a Message to the Current UserNext Topic: Writing to a Printer


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.

Note: 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.