Creating a Subscription for an
Event
Use
To enhance the
process within a BE application, events are provided at different points in
the process. For example, an event exists after the creation of billing
documents and before assignment of the document numbers. If you want to add
enhancements at this point, then you must subscribe to this event.
To subscribe to an
event, you must define a new subscription and assign it to the event. Then,
the template must be programmed and the workbench object generated.
The procedure for
this is described in the example for the new subscription ZSUBSCR, of feature
ZFEATURE, which needs to be assigned to the event BD_OCRE0 in method CREATE,
for object BD (“Billing document”) in application CRMB (“CRM
billing”).
Procedure
-
In the navigation tree, open the folder
“Object”.
-
Open the subobjects for the entry
‘BD’.
-
Open the folder “Function
Group”.
-
Open the subobjects for the entry
‘O – Object Layer’.
-
Open the folder “Function
Module”.
-
Search the list of function modules for
the entry ‘CREATE’.
-
Open the subobjects for the
entry.
-
Open the folder
“Event”.
-
In the list of events, search for the
entry ‘BD_OCRE0’.
-
To display the documentation for this
event, choose “Documentation -> Display” from the context
menu.
-
Open the subobjects for the
entry.
-
Select the folder
“Subscription”.
-
In the function bar of the navigation
tree, choose the function “Display Metadata Entity”.
-
You reach the metadata view for the
subscriptions.
-
From the root node (that is from the
“Subscriptions” folder), call the context menu and choose the
function “Create”.
-
The metadata entry for a subscription is
displayed in a dialog box. Here, enter the value ‘ZSUBSCR’ in the
field ‘Subscription’, enter the value ‘ZFEATURE’ in
the field ‘Feature’, and enter a descriptive text in the field
‘Description’. In the field ‘Program Name’, enter the
name of your template (in your name range). You only need to fill the field
‘Replaced Subscription’, if you want to redefine another
subscription.
In the subscription, you can
specify whether you want to define a template or an ABAP code. If you define
an ABAP code, steps 23 to 25 are not necessary.
-
Save your data changes using the
“Save” function in the dialog box.
-
In the function bar of the navigation
tree, choose the function “Back”. This takes you back to the
display for the events of method ‘CREATE’ for object
‘BD’ in the application view.
-
Call the context menu for the
“Subscription” folder and choose the function “Create
Assignment”.
-
The metadata entry for the assignment of
a feature to an application object is displayed in a dialog box. The
‘Event’ field already has the default value
‘BD_OCRE0’, and the field ‘Application’ already has
the value ‘CRMB’. Here, enter the value ‘ZSUBSCR’ in
the field ‘Subscription’, and in field ‘Sort Sequence’
enter a position in relationship to the other subscriptions.
-
Save your data changes using the
“Save” function in the dialog box.
-
Open the folder
“Subscription”. Your new subscription to the event is
automatically displayed in the appropriate position in the list of
subscriptions.
-
Call the context menu for the entry
‘ZSUBSCR’ and choose the function “Goto ->
Template”.
-
When the system asks whether you want to
create the template, choose “Yes”.
-
You reach the ABAP Editor and can define
entries for your template. The coding must correspond to the rules for
template programming. To avoid syntax errors in the generation syntax, at
least the first column for every line must have a comment asterisk and the
second column must have a space.
-
Generate the function module for the
method CREATE as described in Generating a Workbench
Object.
-
To view the generated coding, call the
context menu for the entry ‘ZSUBSCR’ and choose the function
“Goto -> Generated Code”.
To ensure that the
functionality defined via the subscription is available in the generated
application, the workbench object contained in the event must be regenerated
as described in Generating a Workbench Object.