So after some time at home (parental leave, etc.) today I want to share with you, how and where to change behaviour in the approval procedure easily if you are able to do coding (or in this special case insert the code).
I will not get into approval procedure detail, more information of the this can be found here f.e.:
When using the approval procedure in Change Request Management with more than one approver, the Request for Change is only rejected after all approvers have voted, meaning executed their approval step.
Which means if you have a Request for Change with five approvers and the first one rejects the Request for Change, you have to wait until all approvers voted so the Request for Change is rejected. But it will be rejected as one reject is enough to completely reject the whole Request for Change.
This is the standard behaviour taken over from CRM standard.
Advantages and disadvantages:
The advantages are that all approvers know about the Request for Change and that it might be more convenient that if this has to be clarified with the rejecters, you know all of them in one step.
The disadvantage is that you have to wait until all approvers executed their decision until you get feedback because the Request for Change will nevertheless be rejected.
I was shortly contacted by a customer asking if this could be changed.
The customer wanted that the first reject leads to a general rejection of the Request for Change because it doesn’t make sense for him to wait until others rejected, too. I assume they have a process which allowed to go again into approval from ‘Rejected’ which might not be a ‘FINI’ status at all. But that’s a guess.
Here is now how the behaviour can be implemented:
- Copy a standard function module and change the code
- Register the new function odule instead of the old in the CRM event Framework
The standard behavior evaluating the approval steps and setting the approval procedure is implemented via the CRM Event Framework which can be reached via transaction ‘CRMV_EVENT‘.
There function modules are registered to be called by specified events, like save of the CRM document, etc.
Enter the function name ‘AIC_SRQM_RFC_APPROVAL_STAT_EC’ and press ‘Callback for Cat./Obj./Event’.
You will see that the function is registered to run on the event ‘AFTER_SAVE’ if for the object ‘APPROVAL’ the attribute ‘STEP’ has changed.
This function ‘AIC_SRQM_RFC_APPROVAL_STAT_EC’ has to be replaced by our own copied function ( f.e. ‘Z_SRQM_RFC_APPROVAL_STAT_EC’) with changed code.
To do so, call transaction ‘SE37’, copy the function to the name stated above to an existing function group of your choice and save everything in your transport. Be aware that the top-include of your function group needs the includes
so the copied function module is syntax free.
Then replace the code listed in the screenshot with the code further down and activate everything.
* Replacement code ****
READ TABLE ls_approval_wrk–approval_steps_wrk WITH KEY approval_result = gc_status–request_for_change_rejected TRANSPORTING NO FIELDS.
IF sy–subrc NE 0.
* –4. whether all step are processed
it_approval_s_wrk = ls_approval_wrk–approval_steps_wrk ) EQ true.
lv_approved = true.
LOOP AT ls_approval_wrk–approval_steps_wrk ASSIGNING <fs_approval_s_wrk>
WHERE approval_result EQ gc_status–request_for_change_rejected.
lv_approved = false.
lv_approved = false.
Afterwards register this function in the CRM Event Framework by going into ‘Edit’ mode and entering the new function name.
That’s all. Now the new function with the changed code is called and the Request for Change is set to ‘Rejected’ when the first approver rejects his approval step.
By the way, if you are familiar with the Basis Enhancement Framework ,it is as well possible to replace the code directly in function ‘AIC_SRQM_RFC_APPROVAL_STAT_EC’, then you do not have to change the registration of the function in the CRM Event Framework.
So, hope that helped a bit if you find errors, get in contact with me,