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 :smile:
If somebody need more details, please fill free to ask.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 3143 | |
| 1916 | |
| 1916 | |
| 1213 | |
| 1081 | |
| 757 | |
| 755 | |
| 742 |