Acorel background

Keeping the Service Manager informed via alerts.

Mark Peeters, 06 June 2012

Within the service process, managers want to be informed of any issue that might come up so that they can be proactive in the resolution. For this Blog we sent an alert to the manager of a Call center that a service order has been created that has the priority Very High.
To do this, we will create an action that is triggerd on save, with a schedule condition that the priority is very high. This Action will trigger the alert. In the alert class we determine the manager of the employee that created the Service Order. The standard alert functionality will sent out an email to the email address of the user (SU01) of the manager, and create the alert on the managers home screen.

Creating the alert:

In the transaction alrtcatdef we create a new alert category under the classification ‘CRM service’. You can also link your alert category to a specific user role or authorization profile to sent the alert to a user. For our scenario we will not use this.

On the CONTAINER tab, you can add objects that you want to use in the text. In this example we use the OBJECT_ID that we fill with the service order number. If you add custom objects you will need to fill the object in the Alert Class, we will do this for the OBJECT_ID object.

In the alert category you specify the text for the alert and for the email that will be sent. Within this text you can use the objects from the container by adding an &-sign before and after the object name.

Copy Alert Class:

Standard alerts are handeld by class CL_ACTION_EXECUTE.
Because we want to be able to change the data used in the alert (users and Objects) we copy this class to ZCL_ACTION_EXECUTE. We change the Method TRIGGER ALERT to determine the manager of the employee responsible of the service order.
 In order to send the Alert to the manager, we used the following code:
* now filter the employees.
  LOOP AT lt_partner INTO ls_partner
       WHERE REF_PARTNER_FCT EQ ‘00000014’. “gc_partner_pft-employee.
    CLEAR: ls_recipients.
    CALL FUNCTION ‘BP_CENTRALPERSON_GET’
      EXPORTING
        iv_bu_partner_guid  = ls_partner-bp_partner_guid
      IMPORTING
        ev_username         = ls_recipients-uname
      EXCEPTIONS
        no_central_person   = 1
        no_business_partner = 2
        no_id               = 3
        OTHERS              = 4.
    IF sy-subrc EQ 0 AND
      ls_recipients-uname IS NOT INITIAL.

      CALL FUNCTION ‘BBPU_GET_ORGSTRUCTURE_OF_USER’
        EXPORTING
          username          = ls_recipients-uname
        IMPORTING
         position_id       = lv_position
        EXCEPTIONS
          no_org_data_found = 1
          OTHERS            = 2.
      IF sy-subrc = 0.

        MOVE lv_position TO lv_sobid.

        CALL FUNCTION ‘RH_GET_LEADING_POSITION’
          EXPORTING
            plvar             = ’01’
            otype             = ‘S’
            sobid             = lv_sobid
            date              = sy-datum
          TABLES
            leading_pos       = lt_lead_pos
          EXCEPTIONS
            no_lead_pos_found = 1
            OTHERS            = 2.
        IF sy-subrc = 0.

          READ TABLE lt_lead_pos INTO ls_lead_pos INDEX 1.

          CALL FUNCTION ‘BBP_OM_STRUC_GET_USER_FROM_POS’
            EXPORTING
              position                = ls_lead_pos-objid
              sel_date                = sy-datum
              ppoma_call              = ‘X’
              authority_check         = ‘ ‘
            IMPORTING
              user                    = lv_user
            EXCEPTIONS
              path_not_found          = 1
              error_reading_structure = 2
              no_roots                = 3
              invalid_roots           = 4
              internal_error          = 5
              holder_is_ambiguous     = 6
              user_is_not_assigned    = 7
              OTHERS                  = 8.
          IF sy-subrc <> 0.
*         Implement suitable error handling here
          ENDIF.
        ENDIF.
      ENDIF.

    clear ls_recipients.
    ls_recipients-uname = lv_user.
      INSERT ls_recipients INTO TABLE lt_recipients.
    ENDIF.
  ENDLOOP.

And we add the service order number as object ‘OBJECT_ID’.

    CALL FUNCTION ‘SWC_ELEMENT_SET’
      EXPORTING
        element   = ‘OBJECT_ID’
        field     = ls_orderadm_h_ref-object_id
      TABLES
        container = lt_container
      EXCEPTIONS
        OTHERS    = 1.

Create Action BaDI:

The Alert is triggered by an action so we need to create a new implementation of the BaDI EXEC_METHODCALL_PPF so that we can call our own Alert Class. In SE18, create a new implementation and add the filter value ZTRIGGER_ALERT_PRIO.

In the execute method add the following code:

METHOD IF_EX_EXEC_METHODCALL_PPF~EXECUTE .
  DATA: lc_action_execute  TYPE REF TO zcl_action_execute.
  CREATE OBJECT lc_action_execute.
* copy document
  CALL METHOD lc_action_execute->trigger_alert
    EXPORTING
      io_appl_object     = io_appl_object
      ip_application_log = ip_application_log
      ip_action          = ip_action
      ip_preview         = ip_preview
      ii_container       = ii_container
    IMPORTING
      rp_status          = rp_status.

ENDMETHOD.

Create Action:

In the new action we need to set the Method Call to our new BaDI implementation and add the Processing Parameter Category with name of our Alert Category.

For this action we also set scheduling so that it is automatically scheduled when the priority is high, and we set the maximum successful actions to 1.

Result:

After creating a Service Order with the priority ‘Very High’ the action is triggerd at save. This action creates an alert and sents an email to the manager. On the Home Screen of the Service manager the alert is shown in the assignment blok alerts. When clicking on the alert he navigates to alert

In the alert a direct link to service order is available in the alert in the assignment block Subsequent Actions. The alert can be completed by the manager once he has acted on it, the alert will then disappear from his home screen.

The email contains the text that was set-up in the alert category.

Mark Peeters

Read all my blogs

Receive our weekly blog by email?
Subscribe here:

More blogs