Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Purpose of doing:

We do this to send the mails to your external inbox from SAP Inbox. The mails will go to only those users whose mail ID is maintained.

Notification Handler Class: - YCL_SWN_NOTIF_WORKFLOW

Purpose:-

We are also going to create a custom notification handler class which we are going to use it to add hyperlink while sending the mail from SAP Inbox to the Outer mail box. We are going to declare this while doing Extended Notification Configuration.

Step1:

Go to transaction SE24 and create a sub class YCL_SWN_NOTIF_WORKFLOW.The super class of this sub class is CL_SWN_NOTIF_WORKFLOW.

Step2:

Create a new method ADD_LINK_ACTION_EXECUTE. This method is used to add the Hyperlink of the order. Whenever this Link is clicked it will take you to Order in Web UI.

Method : - ADD_LINK_ACTION_EXECUTE

Changing Parameter    : - C_LINKS, Type: - SWNTLINKS.

Method Logic :-

Step1:-

Get all the values of the workflow container from the Workitem created by the workflow based on the Workitem ID with the help of FM SWW_WI_CONTAINER_READ.

M_WI_HEADER is a global attribute which holds all the Workitem related header data.

  CALL FUNCTION 'SWW_WI_CONTAINER_READ'
   
EXPORTING
      wi_id                    = m_wi_header-wi_id
   
TABLES
      wi_container             = i_cont
   
EXCEPTIONS
      container_does_not_exist =
1
      read_failed              =
2
     
OTHERS                   = 3.

Step2:-

Get the values of the element “_WI_OBJECT_ID” from the container. This holds the BOR and the GUID.

Step3:-

Determine UI object of the BOR based on the Header GUID, Object Type and Logical system with the help of class “CL_CRM_UI_OBJECT_MAPPING_SRV” and method “DETERMINE_UI_OBJECT_OF_BOR”.

      lv_bor_object_key = i_wa_orderadm_h-guid.

     
CALL METHOD cl_crm_ui_object_mapping_srv=>get_instance
        RECEIVING
          rv_result = lr_mapping_srv.

      lr_bol_core = cl_crm_bol_core=>get_instance( ).
      lr_bol_core->start_up( iv_appl_name =
'BT'
                             iv_display_mode_support = abap_true ).

     
CALL METHOD lr_mapping_srv->determine_ui_object_of_bor
       
EXPORTING
          iv_bor_object_key  = lv_bor_object_key
          iv_bor_object_type = i_wa_orderadm_h-object_type
          iv_logical_system  = i_wa_orderadm_h-logical_system
        RECEIVING
          rv_result          = lv_ui_object_type.

Step4:-

Get the URL for the Order in web UI using class CL_CRM_WEB_UTILITY and method CREATE_URL.

      CONCATENATE
        lc_par1 lv_ui_object_type
        lc_par2 lc_display
        lc_par3 w_guid_string
     
INTO lv_query.

     
CALL METHOD cl_crm_web_utility=>create_url
       
EXPORTING
          iv_absolute        = abap_true
          iv_query           = lv_query
          iv_bsp_application = lc_bsp_application
          iv_bsp_page        = lc_bsp_page
        RECEIVING
          ev_url             = lv_url.

Step5:-

Populate C_LINK with the URL you have fetched and the hyperlink name that will appear in the mail.

        wa_link-category = swn1_ref_type_tech. ”('T')
        wa_link-
id = swn1_ref_id_execute.      ”(EXECUTE_LINK_URL)
        wa_link-caption =
'Execute Work Item'(002).
        wa_link-url = lv_url.
       
APPEND wa_link TO c_links.
       
CLEAR wa_link.

Program( Sample Code for Hyperlink):-

METHOD add_link_action_execute.

  CONSTANTS:
  lc_bsp_application TYPE string VALUE 'CRM_UI_START',
  lc_bsp_page        TYPE string VALUE 'DEFAULT.HTM',
  lc_par1            TYPE string VALUE 'crm-object-type=',
  lc_par2            TYPE string VALUE '&crm-object-action=',
  lc_par3            TYPE string VALUE '&crm-object-value=',
  lc_ui_object_type  TYPE bsp_dlc_object_type VALUE 'WORKITEM_IB',
  lc_display         TYPE crmt_ui_actions   VALUE 'B'.


  DATA: lv_url             TYPE agr_url,
        lv_query           TYPE string,
        i_wa_orderadm_h    TYPE crmt_orderadm_h_wrk,
        lv_bor_object_key  TYPE swo_typeid,
        lv_ui_object_type  TYPE bsp_dlc_object_type,
        lr_mapping_srv     TYPE REF TO cl_crm_ui_object_mapping_srv,
        lr_bol_core        TYPE REF TO cl_crm_bol_core.

  DATA:wa_link       TYPE swnslink,
       i_cont        TYPE STANDARD TABLE OF swcont,
       i_wa_cont     LIKE LINE OF i_cont,
       w_string      TYPE string,
       w_string1     TYPE string,
       w_guid_string TYPE string,
       lv_item_guid  TYPE crmt_object_guid,
       l_header_guid TYPE crmt_object_guid.

  CALL FUNCTION 'SWW_WI_CONTAINER_READ'
    EXPORTING
      wi_id                    = m_wi_header-wi_id
    TABLES
      wi_container             = i_cont
    EXCEPTIONS
      container_does_not_exist = 1
      read_failed              = 2
      OTHERS                   = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  READ TABLE i_cont INTO i_wa_cont WITH KEY element = '_WI_OBJECT_ID'.
  CHECK sy-subrc EQ 0.

  w_string = i_wa_cont-value+10(6).
  w_string1 = i_wa_cont-value+10(10).

  IF w_string EQ 'YORDER'.

    w_guid_string = i_wa_cont-value+20(32).

    CHECK w_guid_string IS NOT INITIAL.

    l_header_guid = w_guid_string.

    CALL FUNCTION 'CRM_ORDERADM_H_READ_OW'
      EXPORTING
        iv_orderadm_h_guid     = l_header_guid
      IMPORTING
        es_orderadm_h_wrk      = i_wa_orderadm_h
      EXCEPTIONS
        admin_header_not_found = 1
        OTHERS                 = 2.

    IF sy-subrc =0.

      lv_bor_object_key = i_wa_orderadm_h-guid.

      CALL METHOD cl_crm_ui_object_mapping_srv=>get_instance
        RECEIVING
          rv_result = lr_mapping_srv.

      lr_bol_core = cl_crm_bol_core=>get_instance( ).
      lr_bol_core->start_up( iv_appl_name = 'BT'
                             iv_display_mode_support = abap_true ).

      CALL METHOD lr_mapping_srv->determine_ui_object_of_bor
        EXPORTING
          iv_bor_object_key  = lv_bor_object_key
          iv_bor_object_type = i_wa_orderadm_h-object_type
          iv_logical_system  = i_wa_orderadm_h-logical_system
        RECEIVING
          rv_result          = lv_ui_object_type.

      IF lv_ui_object_type IS INITIAL.
        lv_ui_object_type = 'BT115_SLSO'.
      ENDIF.

      CONCATENATE
        lc_par1 lv_ui_object_type
        lc_par2 lc_display
        lc_par3 w_guid_string
      INTO lv_query.

      CALL METHOD cl_crm_web_utility=>create_url
        EXPORTING
          iv_absolute        = abap_true
          iv_query           = lv_query
          iv_bsp_application = lc_bsp_application
          iv_bsp_page        = lc_bsp_page
        RECEIVING
          ev_url             = lv_url.


      IF lv_url IS NOT INITIAL.
        wa_link-category = swn1_ref_type_tech.
        wa_link-id = swn1_ref_id_execute.
        wa_link-caption = 'Execute Work Item'(002).

        wa_link-url = lv_url.
        APPEND wa_link TO c_links.
        CLEAR wa_link.

      ENDIF.
    ENDIF.

  ELSEIF w_string1 EQ 'BUS2000131' OR
         w_string1 EQ 'YBUS200131'.

    w_guid_string = i_wa_cont-value+20(32).

    CHECK w_guid_string IS NOT INITIAL.

    lv_item_guid = w_guid_string.

    CALL FUNCTION 'CRM_ORDER_GET_HEADER_GUID'
      EXPORTING
        iv_ref_guid     = lv_item_guid
        iv_ref_kind     = 'B'
      IMPORTING
        ev_header_guid  = l_header_guid
      EXCEPTIONS
        not_found       = 1
        parameter_error = 2
        OTHERS          = 3.

    IF sy-subrc IS INITIAL.

      CALL FUNCTION 'CRM_ORDERADM_H_READ_OW'
        EXPORTING
          iv_orderadm_h_guid     = l_header_guid
        IMPORTING
          es_orderadm_h_wrk      = i_wa_orderadm_h
        EXCEPTIONS
          admin_header_not_found = 1
          OTHERS                 = 2.

      IF sy-subrc = 0.

        lv_bor_object_key = i_wa_orderadm_h-guid.

        CALL METHOD cl_crm_ui_object_mapping_srv=>get_instance
          RECEIVING
            rv_result = lr_mapping_srv.

        lr_bol_core = cl_crm_bol_core=>get_instance( ).
        lr_bol_core->start_up( iv_appl_name = 'BT'
                               iv_display_mode_support = abap_true ).

        CALL METHOD lr_mapping_srv->determine_ui_object_of_bor
          EXPORTING
            iv_bor_object_key  = lv_bor_object_key
            iv_bor_object_type = i_wa_orderadm_h-object_type
            iv_logical_system  = i_wa_orderadm_h-logical_system
          RECEIVING
            rv_result          = lv_ui_object_type.

        w_guid_string = l_header_guid.

        IF lv_ui_object_type IS INITIAL.
          lv_ui_object_type = 'BT115_SLSO'.
        ENDIF.

        CONCATENATE
          lc_par1 lv_ui_object_type
          lc_par2 lc_display
          lc_par3 w_guid_string
        INTO lv_query.

        CALL METHOD cl_crm_web_utility=>create_url
          EXPORTING
            iv_absolute        = abap_true
            iv_query           = lv_query
            iv_bsp_application = lc_bsp_application
            iv_bsp_page        = lc_bsp_page
          RECEIVING
            ev_url             = lv_url.


        IF lv_url IS NOT INITIAL.
          wa_link-category = swn1_ref_type_tech.
          wa_link-id = swn1_ref_id_execute.
          wa_link-caption = 'Execute Work Item'(002).

          wa_link-url = lv_url.
          APPEND wa_link TO c_links.
          CLEAR wa_link.

        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.

ENDMETHOD.

Configuration of Extended Notification:-

Prerequisites

·        Your are able to send e-mail

·        The SAP Web Application Server must be configured for BSP applications

·        You have activated the following services in transaction SICF (HTTP Service Hierarchy Maintenance).

  1. Service for calling the administration application:
  2. default_host->sap->bc->bsp->sap->swn_config
  3. Service for creating message contents:
  4. default_host->sap->bc->bsp->sap->swn_message1
  5. Service for executing a user decision:
  6. default_host->sap->bc->bsp->sap->swn_wiexecute
  7. Services for displaying or executing work items or displaying the Workflow inbox by using executable attachments:
  8. default_host->sap->bc->workflow->shortcut
  9. default_host->sap->public->bc->workflow->shortcut

Process Flow

Use transaction code SWNCONFIG.

1.    Defining the Category

If later you want to define different subscriptions for work items of particular tasks, define corresponding categories as the basis for these subscriptions. 

2.    Defining the Selection

You define which work items are to be included and when the selection is to take place. Furthermore, you define the category to which the work items will be assigned.

3.    Defining Subscriptions

You define who receives notifications for work items of a particular category and when, how the messages are structured, and whether they are sent as an e-mail or SMS. 

4.    Defining the General Settings

You have the option of customizing the standard text that is used for creating messages, for example.

5.    Scheduling the Report for Selection and delivery

The actual selection of work items or delivery of notifications is performed by the report SWN_SELSEN. To execute the report you need to schedule a corresponding job.

6.    Scheduling the Report for Deleting Completed Notifications

7.    To stop the database from expanding too rapidly, you can schedule a report to delete completed notifications as a background job or you can execute it immediately.

Configuration Steps:-

Step1:-

Run Transaction codes SWNCONFIG -> choose WORKFLOW and double click on Category.

Step2:-

Choose New Entries (F5)

Create a Category named YSALES and choose the appropriate parameters from the Drill-down menus and Save (Ctrl+S).

Over here we are going to specify the custom Notification class which we have created above under Notification handler.

Below a screenshot with the appropriate entries added to YSALES.

Step3:-

Create a Delivery Schedule named YSALESSCHEDULE and choose the appropriate parameters from the Drill-down menus and Save (Ctrl+S)

Below a screenshot with the appropriate entries added to YSALESSCHEDULE.

Step4:-

Double-click on Filter Basic Data and choose New Entries (F5).

Create two new entries, one for Full and one for Delta. We are going to create filter basic data named YSALESFULL and YSALESDELTA.

Below a screenshot with the appropriate entries added to YSALESFULL.

Below a screenshot with the appropriate entries added to YSALESDELTA.

Step5:-

Choose YSALESFULL and double click on Filter settings. Add the Task from where your mails are getting generated. In our case it is TS90100004. We can also specify multiple Tasks over as show in the below screen shot.

Choose YSALESDELTA and double click on Filter settings. Add the Task from where your mails are getting generated and make Delta as ‘X’. In our case it is TS90100004. We can also specify multiple Tasks over as show in the below screen shot.

Step6:-

Double click on Subscription Basic Data and make sure that Scenario ID is WORKFLOW and Category ID is YSALES (same as the one created in earlier step) and Press enter.

Below is the screenshot with the correct entries.

Enter the values as shown. You may get the following warning (just confirm it).

Step7:-

Choose New Entries (F5) and Create a Subscription named YSALESSUB and choose the appropriate parameters from the Drill-down menus and Save (Ctrl+S).

Below a screenshot with the appropriate entries added to YSALESSUB.

NOTE:- That the Recipient Address needs to be your userid (you need to have an email address connected to your userid see SU01) during the test & verification process of the workflow, otherwise you might spam everyone…

You change this after a successful test to * (Asterisk)

Step8:-

Double click on subscription script. Add the appropriate parameters from the Drill-down menus Save (Ctrl+s).

Below is the screenshot with the correct entries.

Step9:-

Double click on Schedule Selection and Choose New Entries (F5).

Create a Schedule Selection named YSALESSCHEDFULL and add the appropriate parameters from the Drill-down menus and Save (Ctrl+s).

Below is the screenshot with the correct entries.

Create a Schedule Selection named YSALESSCHEDDELTA and add the appropriate parameters from the Drill-down menus and Save (Ctrl+S) as shown above for YSALESSCHEDFULL.

Step10:-

Double click on General Settings.

Add values to the following settings

INBOX_LINK_URL = Link to Alternative Inbox, for Example UWL

SENDER_ADDR_INT = E-Mail Address to Be Used as Sender

WD_HOST = Give the Host Part of URLs that Reference WebDynpro.

WG_HOST = Give the Host Part of URLs that Reference SAP GUI for HTML. WI_FORWARD_VIA_MAIL = ‘X’

NOTE: The entries referring to host names have to be changed when the request is imported into the target system.

Step11:-

Double-click the entry Assigned Message Templates and click on “New entries”.Create an entry as shown below and save the configuration.

Step12:

The actual selection of work items or delivery of notifications is performed by the report SWN_SELSEN.

Schedule report SWN_SELSEN as a background job as per the requirement.

Summary:-

After these we are capable of creating a workflow and sending it to any external mail box.

7 Comments