In one of the scenarios an email had to be sent to the employee responsible whenever an activity was assigned to him/her. The email had to contain a hyperlink which when clicked would launch the transaction on CRM Web UI. An easy way of doing that is using PPF Actions.

1. Action Example

Let’s look at the SAP standard action profile “ACTIVITY” which is quite close to what we want to do.

Action Profile – ACTIVITY


Action Definition – ACTIVITY_REMINDER_MAIL (Note – Partner Dependent, which means only when a partner with that partner function is assigned to the transaction will the action be determined)


Processing Type – Smart Forms Mail


TipIf you want the email alert to be sent to only once per person then on the action definition set the “Action Merging” property to “Set Highest Number of Processed Actions” which will enable the “Action Merging” tab where you will be able to specify that the system should allow a maximum of 1 successful action.



2. Prerequisites

A. Copy the smartform CRM_REMINDER_MAIL_01  into ZCRM_REMINDER_MAIL_01 and convert the transaction id into a hyperlink.


B. Create a new class ZCL_DOC_PROCESSING_CRM_ORDER deriving from CL_SF_PROCESSING_PPF and create the methods similar to the SAP class CL_DOC_PROCESSING_CRM_ORDER.



METHOD class_constructor.

  CALL METHOD cl_exithandler=>get_instance
      exit_name              = ‘CRM_ACTION_BADI’  “#ec notext
      null_instance_accepted = ‘X’
      instance               = gr_action_badi.


Copy and paste the code from the SAP standard class into the method CRM_ORDER_EXEC_SMART_FORM. After the data definitions in the method add the name of the callback function module as below –

* fill internal structure for the output options
  ls_output_options = is_output_options. “Add line below after this line.
  ls_output_options-urlcall = ‘Z_ALERT’.

C. Create the function module Z_ALERT. Make sure you add a default to the parameter IV_BUSINESS_ROLE to point to the crm business role that will be launched when the URL in the smartform is clicked. Make sure that the business role has the outbound plug mapping maintained as shown in the screenshot below.


FUNCTION z_alert.
*”*”Local Interface:

  INCLUDE rstxscad.
  CONSTANTS: cv_line_length TYPE i VALUE 42.

  DATA: l_str TYPE string.

  DATA: lv_base_url        TYPE string,
        lv_bp              TYPE bu_partner,
        lv_sso_active      TYPE flag.

  DATA: lr_appl_model TYPE REF TO if_bsp_wd_appl_model.

        lv_offset      TYPE i,
        lv_length      TYPE i,
        lv_guid_char   TYPE sysuuid_c,
        lv_guid        TYPE sysuuid_x,
        lv_url         TYPE string,
        ls_xctoken     TYPE LINE OF ttxctoken,
        lv_order_id    TYPE crmt_object_id_db.

  FIELD-SYMBOLS: <ls_xctoken>   TYPE LINE OF ttxctoken.

* extraxt order_id
  READ TABLE data ASSIGNING <ls_xctoken>
        WITH KEY code = ‘ST’.

  IF <ls_xctoken> IS ASSIGNED.
    lv_order_id = <ls_xctoken>-string.

    IF lv_order_id IS NOT INITIAL.

        iv_bsp_appl   = ‘CRM_UI_START’
        iv_model_type = ‘CL_BSP_WD_APPL_MODEL_RTTI’
        rv_model      = lr_appl_model
        OTHERS          = 1 ).

      CHECK lr_appl_model IS BOUND.

      lv_base_url = lr_appl_model->get_start_url( ).
      gv_url = lv_base_url.

*  PERFORM add_url_param USING ‘sap-language’ sy-langu.

      IF iv_business_role IS NOT INITIAL.
        PERFORM add_url_param USING ‘saprole’ iv_business_role.

      PERFORM add_url_param USING ‘crm-object-type’ ‘BT126H_APPT’.
      PERFORM add_url_param USING ‘crm-object-action’ iv_action.
      PERFORM add_url_param USING ‘crm-object-keyname’ ‘OBJECT_ID’.
      PERFORM add_url_param USING ‘crm-object-value’ lv_order_id.

      DELETE data WHERE code = ‘LK’.

      lv_length = strlen( gv_url ).
      lv_offset = 0.

      ls_xctoken-code = ‘LK’.
      ls_xctoken-line = -1.
      ls_xctoken-len  = cv_line_length.
      ls_xctoken-string = space.

      WHILE lv_length > 0.

        ls_xctoken-code = ‘LK’.
        ls_xctoken-len  = cv_line_length.
        ls_xctoken-string = space.
        ls_xctoken-line = ls_xctoken-line + 1.

        IF lv_length > cv_line_length.
          ls_xctoken-string+4(cv_line_length) = gv_url+lv_offset.
          lv_offset = lv_offset + cv_line_length.
          lv_length = lv_length – cv_line_length.
          ls_xctoken-string+4(lv_length) = gv_url+lv_offset.
          ls_xctoken-len = lv_length.
          lv_length      = 0.
        APPEND ls_xctoken TO data.



In the function group include add the following –

DATA gv_url(4096) TYPE c.

FORM add_url_param USING iv_param  TYPE string
      iv_value  TYPE ANY.

  IF gv_url CA ‘?’.
    CONCATENATE gv_url ‘&’ iv_param ‘=’ iv_value INTO gv_url. “#EC NOTEXT
    CONCATENATE gv_url ‘?’ iv_param ‘=’ iv_value INTO gv_url. “#EC NOTEXT


1.   3. Action Definition

With all the prerequisite steps complete we are now ready to create the action. I assume there is already an action profile assigned to the transaction type in context here. We can now go ahead and create the action similar to the SAP standard action only to replace the action handler class to our Z class and the smartform to our Z smartform.

After the action definition is complete the next step is to define the action condition which can be done using the IMG Activity “Define Conditions”. Here you can specify conditions like don’t send the alert If the status is closed etc.


4. End result would be that whenever an employee is assigned to that transaction an email will go out to the employee which will contain a hyperlink on the transaction ID which when clicked will open the transaction on CRM Web UI using the role specified in the call back function module.

1.   5. Troubleshooting

  • Enable the Actions assignment block on the transaction and check the determination and execution trace.
  • For the email to go out to the employee the email address has to be maintained on the address information of the employee record.
  • Check SCOT settings to make sure that an SMTP node is determined for the email address.
  • Smartforms will be emailed as PDF attachments based on the SCOT setting
  • In development systems the job that sends email out is usually not scheduled so you might have to push emails out manually using SOST.


  • If everything looks ok then run an authorization trace (ST05) to check if a missing auth is preventing from email from being sent. Usually the object S_OC_SEND is the cause of the authorization problem.
To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. akshay ruia


    What logic have u written in routine add_url_param.

    Can u write the complete logic step wise in words. It would be really greatful.



  2. Sanket Chimalwar

    Hi Gaurav,

    Thanks for this post. I was missing something in my code and ur code helped to solve that mystery in the Z function module. But i face something different now. In the SOST when i see the details of my mail. I see a number ( Object_id ) as hyperlink ( example 70203 ) as expected and a hyperlink for that number and when i actually receive the email, instead of the number with hyperlink i receive the link.

    As an example -:

    OBJECT_ID ( 70203) is to be masked by

    IN SOST i see the following in my mail body

    Transaction ID : 70203

    But in actual mail i get

    Transaction ID :

    Do you have any idea why this happens ??

    Kind regards


        1. Gaurav walia Post author

          Hi Sanket,

          In this article here I’ve described a PDF output. If HTML isn’t a requirement then you can change the HTML output to PDF output easily in SCOT settings.

          Kind regards,



Leave a Reply