Communication by event between programmes
In Greek mythology, the gods’ most commonly used means of communication with mortals was rape. They would rape for no reason whatsoever.
The closest thing we have to rape in ABAP is the command “SUBMIT”, which is also the most common way of communicating between two programmes.
But there are less crude ways for a programme to communicate with another, e.g. by using an event.
Let’s imagine you have a programme called ZEUS (strictly speaking, it would be ZEUS_TOURO, but OK) that wants to communicate with another called ZEUROPA.
-
In the SM62 transaction, you create the event with a type Z* name. Let’s call it ZAS! Once it is created, you can find it near the end of the long list of events, next to the other events created by the client;
-
If you right-click, you can do a whole lot of things with it. One of these is to transport it, i.e. add it to a transport order;
-
In the ZEUS programme, in the place where ZEUROPA should be called up, enter the following code:
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
eventid = 'ZAS'
EXCEPTIONS
BAD_EVENTID = 1
EVENTID_DOES_NOT_EXIST = 2
EVENTID_MISSING = 3
RAISE_FAILED = 4
OTHERS = 5
-
In the SM36 transaction, create a job ZEUS_ZAS_EUROPA with a single step, the execution (heaven forbid) of ZEUROPA;
-
In the execution conditions of the job choose the option “after event” and select the ZAS event. Save.
Alright then. When you run the ZEUS programme, It launches the event ZAS, Which triggers the job ZEUS_ZAS_EUROPA, Which executes (heaven forbid) ZEUROPA.
Greetings from Abapinho.