Email to Approvers in Approval Assigment Block
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 )
As you can see we have 2 Context nodes BTADMINH and BTAPPROVALSTEPS
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
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
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.
Hi why you rising this here? create separate discussion in Solman Space.
And you get your help there.
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!
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 🙂
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
Hi Dilip,
This functionality is not available as of Solman 7.1 SP12 as a standard feature. You may go through this to know more on limitations and features;
http://scn.sap.com/community/it-management/alm/solution-manager/blog/2015/03/06/charm-in-71-extracts-from-a-consultant-diary
Thanks,
Vivek
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
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.
Hi Robyn,
Thanks for the reply, I will try to work on this.
If I can get through, will post.
Regards,
Dillip