Trigger / Event Management between Programs in Different ABAP Sessions

I have two programs that work in split sessions. I want to send an event from program A and catch this event in program B.

How can i do this?

+4
source share
2 answers

Using class-based events is not really an option, since they cannot be used to communicate between user sessions.

There is a mechanism that you can use to send messages between sessions: ABAP Messaging Channels . You can send anything that is either a text string, a byte string, or can be serialized in any of the above.

, SE80 ( > > ABAP) Eclipse ADT (New > ABAP Messaging Channel Application).

:

  • (text vs binary)
  • ABAP, .
  • (.. ?) ?

. ( A) ( B). , , .

:

 " publishing a message
 CAST if_amc_message_producer_text(
     cl_amc_channel_manager=>create_message_producer(
     i_application_id = 'DEMO_AMC'
     i_channel_id     = '/demo_text'
     i_suppress_echo  = abap_true )
 )->send( i_message = text_message ).

 " subscribing to a channel
 DATA(lo_receiver) = NEW message_receiver( ).
 cl_amc_channel_manager=>create_message_consumer(
     i_application_id = 'DEMO_AMC'
     i_channel_id     = '/demo_text'
 )->start_message_delivery( i_receiver = lo_receiver )

 " waiting for a message
 WAIT FOR MESSAGING CHANNELS 
     UNTIL lo_receiver->text_message IS NOT INITIAL
     UP TO time SECONDS.

B - , WAIT FOR... RFC RFC aRFC. B, . , aRFC, RFC.

RFC WAIT EXPORTING. - :

CALL FUNCTION 'ZMY_AMC_WRAPPER' STARTING NEW TASK 'MY_TASK'
    CALLING lo_listener->my_method ON END OF TASK.

" inside your 'listener' class implementation
METHOD my_method.
    DATA lv_message TYPE my_message_type.
    RECEIVE RESULTS FROM FUNCTION 'ZMY_AMC_WRAPPER'
        IMPORTING ev_message = lv_message.
    " do something with the lv_message
ENDMETHOD.
+4

, B, SAP . A . (.. SET/GET PARAMETER...). B.

. , ? B , , A , ( A , )...

: ABAP, Seban ,

0

Source: https://habr.com/ru/post/1692706/


All Articles