Skip to Content

In this blog i will show how you can send Emails to Approver Partner ID’s in approval assignment block.

Hence there is not standard customization yet, you need some development.

In this example we will Send Emails to Approver Partner ID’s whose step have initial value <> not approved/rejected/not relevant.

If approval result is not empty email will not be send.

Solution consist of 2 steps:

1) Read conent of Approval Assigment block ( static – from tables or dynamic – from BSP )

2) Send mails via ppf_action to recipients collected in step 1

Step 1 Read content of Approval Assigment block

You can read content of Assigment block directly from crm table CRM_APPROVAL_S.

How to read this table:

take CRMD_ORDERADM_H-GUID go to CRMD_LINK-GUID_HI = CRMD_ORDERADM_H-GUID

now get CRMD_LINK-GUID_SET where Object_type = 50

CRM_APPROVAL_S-PARENT_GUID = CRMD_LINK-GUID_SET.

But this table conatins of values as is, so if you change content of it f.e. change partner_id to new, changes will be available only after save. So if you schedule action “processing after save” this will not work. For this we will Enhance related BSP application “BT_APPROVAL”.

How to enhance BSP application = http://wiki.sdn.sap.com/wiki/display/CRM/How+To+Enhance+a+Web+UI+Component+in+SAP+CRM

Ok now our BT_APPROVAL is enhanced, next enhance View BT_APPROVAL/ApprovalStepEL ( right click -> enhance )

/wp-content/uploads/2013/05/bt_approval_1_216582.png

As you can see we have 2 Context nodes BTADMINH and BTAPPROVALSTEPS

/wp-content/uploads/2013/05/bt_approval_2_216668.png

To read data from BTADMINH in BTAPPROVALSTEPS methods you can use technology from this wiki

How to read one context node data in other context node http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=201066680

You can use your own field or methods i tooked field Partner_no and its method Get_parnter_no

/wp-content/uploads/2013/05/bt_approval_3_216669.png

you can collect value of all lines dynamicly in this method

example code :

* call super
  CALL METHOD super->get_partner_no
    EXPORTING
      attribute_path = ''
      iterator       = iterator
    RECEIVING
      value          = value.
  DATA:
        lv_current TYPE REF TO if_bol_bo_property_access
       ,l_approval_result TYPE string
       ,l_guid TYPE string
       ,ls_recipients TYPE crmt_approval_s_wrk
       ,lr_btadminh TYPE REF TO cl_crm_bol_entity
       ,l_object_type TYPE string
       .
  IF iterator IS BOUND.
    lv_current = iterator->get_current( ).
  ELSE.
    lv_current = collection_wrapper->get_current( ).
  ENDIF.
*get data from BTADMINH
  IF gr_owner IS BOUND.
    lr_btadminh ?= gr_owner->btadminh->collection_wrapper->get_current( ).
*current transactions GUID
    IF lr_btadminh IS BOUND.
      l_object_type = lr_btadminh->if_bol_bo_property_access~get_property_as_string( iv_attr_name = 'GUID' ).
    ENDIF.
  ENDIF.
  l_approval_result = lv_current->get_property_as_string( 'APPROVAL_RESULT' ).
  CHECK sy-subrc = 0.
  l_guid = lv_current->get_property_as_string( 'GUID' ).
  CHECK sy-subrc = 0.
* collect partner_no and approval result
  ls_recipients-partner_no = value.
  ls_recipients-approval_result = l_approval_result.
  ls_recipients-guid = l_guid.
  ls_recipients-parent_guid = l_object_type.
  TRY .
      CALL FUNCTION 'ZSOLE001_RECIPIENTS' " FM collects actual values of assigment block
        EXPORTING
          i_recipients = ls_recipients.
    CATCH cx_root.
  ENDTRY.

Step 2 Send mails via ppf_action to recipients collected in step 1

Okay now we need to send emails to recipients, in this example i will use ppf action with processing type – method call

First we need to create BADI SE18 BADI name = EXEC_METHODCALL_PPF – filter value – create

/wp-content/uploads/2013/05/bt_approval_4_216670.png

Here im getting table from FM ‘ZSOLE001_RECIPIENTS’  where i did collected recipients.

    LOOP AT lt_recipients INTO ls_recipients
      WHERE approval_result = space AND step_type = 'O'.
          send_mail( EXPORTING i_recipients = ls_recipients
                           io_partner = io_partner
                           io_appl_object = io_appl_object
                           i_output = ls_output
                           ip_application_log = ip_application_log
                           i_control_parametrs = ls_control_parametrs
                 CHANGING  rp_status = rp_status ).
    ENDLOOP.

ok now done ๐Ÿ™‚

If somebody need more details, please fill free to ask.

To report this post you need to login first.

8 Comments

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

  1. Robyn Osby

    Hi Daniyar,

    I know your blog post is old, but I’m hoping you remember some of the details. I need to trigger emails to two Approvers sequentially (Approver1, then after that approver, send to Approver2).  I have tried using the Workflow functionality, but the emails contain the link to the SAP Inbox and the flow is very awkward to get to the RfC approval screen.

    I’m interested in trying your approach. Will your changes work for sequential emails to more than one Approver? I need the second email to wait until the first is approved.

    What are your thoughts?  And thank you in advance for your feedback!

    (0) 
    1. Former Member Post author

      Hi Robyn,

      Yes and Yes. You can read the sequance and result from approval buffer, but this requires ABAP skill.

      with FM ‘CRM_APPROVAL_READ_OW’ you may read all approvals from buffer.

      then loop at them with rule  approval_result = space, table is sorted by default. But you can sort it by sequance.

      when you find a row with approval_result = space, send email and exit loop.

      That’s all ๐Ÿ™‚

      (0) 
    2. Former Member

      Hi Robyn,

      I hope you could share me with some details on the email trigger in sequential way to the approvers (multiple but in sequential way).

      We have the same requirement has you have described, could you help me in achieving the same.

      Thanks,

      Dillip

      (0) 
        1. Former Member

          Hello Vivek,

          That link was one of the informative post for me to help on with ChaRM.

          Would you please help with hints on how to convert inbox worklist email to outlook/inbox email notifications.

          Regards,

          Dillip

          (0) 
      1. Robyn Osby

        Hi Dillip,

        Our requirement changed since then. We are sending the emails to 2 approvers simulateously, so I did not implement changes for sequential emails. Sorry.

        (0) 

Leave a Reply