Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Data Interfaces and Communication Interfaces →  ABAP Channels →  AMC - ABAP Messaging Channels →  AMC Examples 

AMC, Suppressing Standalone Messages

This example demonstrates the suppression of AMC messages to the current ABAP session.

Other versions: 7.31 | 7.40 | 7.54

Source Code

REPORT demo_amc_suppress_echo.

CLASS message_receiver DEFINITION.
  PUBLIC SECTION.
    INTERFACES:
      if_amc_message_receiver_text.
    DATA text_message TYPE string.
ENDCLASS.

CLASS message_receiver IMPLEMENTATION.
  METHOD if_amc_message_receiver_text~receive.
    text_message = i_message.
  ENDMETHOD.
ENDCLASS.

CLASS amc_demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
ENDCLASS.

CLASS amc_demo IMPLEMENTATION.
  METHOD main.
    DATA(receiver) = NEW message_receiver( ).
    TRY.
        cl_amc_channel_manager=>create_message_consumer(
            i_application_id = 'DEMO_AMC'
            i_channel_id     = '/demo_text'
            )->start_message_delivery( i_receiver = receiver ).
      CATCH cx_amc_error INTO DATA(text_exc).
        cl_demo_output=>display( text_exc->get_text( ) ).
    ENDTRY.

    "Check 'Send text message' and toggle 'Suppress echo'
    SUBMIT demo_send_amc AND RETURN.

    WAIT FOR MESSAGING CHANNELS
      UNTIL receiver->text_message IS NOT INITIAL
      UP TO 1 SECONDS.

    IF receiver->text_message IS NOT INITIAL.
      cl_demo_output=>display( receiver->text_message ).
    ENDIF.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  amc_demo=>main( ).

Description

Like in the executable example for Receiving Messages, a receiver object for the messaging channel /demo_text of the application DEMO_AMC from the package SABAPDEMOS is registered. In the example shown here, the text message can be sent by calling the program DEMO_SEND_AMC from the example Sending Messages within the same ABAP session.

The message is only received if the initial value is transferred during sending to the parameter I_SUPPRESS_ECHO of the method CREATE_MESSAGE_PRODUCER. If the Suppress echo checkbox is selected, on the other hand, the message is suppressed.