Show TOC Start of Content Area

Function documentation Creating a Subscription for an Event  Locate the document in its SAP Library structure

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

  1. In the navigation tree, open the folder “Object”.
  2. Open the subobjects for the entry ‘BD’.
  3. Open the folder “Function Group”.
  4. Open the subobjects for the entry ‘O – Object Layer’.
  5. Open the folder “Function Module”.
  6. Search the list of function modules for the entry ‘CREATE’.
  7. Open the subobjects for the entry.
  8. Open the folder “Event”.
  9. In the list of events, search for the entry ‘BD_OCRE0’.
  10. To display the documentation for this event, choose “Documentation -> Display” from the context menu.
  11. Open the subobjects for the entry.
  12. Select the folder “Subscription”.
  13. In the function bar of the navigation tree, choose the function “Display Metadata Entity”.
  14. You reach the metadata view for the subscriptions.
  15. From the root node (that is from the “Subscriptions” folder), call the context menu and choose the function “Create”.
  16. 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.

NoteIn 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.

  1. Save your data changes using the “Save” function in the dialog box.
  2. 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.
  3. Call the context menu for the “Subscription” folder and choose the function “Create Assignment”.
  4. 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.
  5. Save your data changes using the “Save” function in the dialog box.
  6. Open the folder “Subscription”. Your new subscription to the event is automatically displayed in the appropriate position in the list of subscriptions.
  7. Call the context menu for the entry ‘ZSUBSCR’ and choose the function “Goto -> Template”.
  8. When the system asks whether you want to create the template, choose “Yes”.
  9. 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.
  10. Generate the function module for the method CREATE as described in Generating a Workbench Object.
  11. 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.

 

End of Content Area