If the approver is trying to reject the shopping cart then approver should enter a rejection reason. If approver not entered any rejection reason and clicked on REJECT button then a popup should be displayed to enter the rejection reason. If the user entered reason and press on ADD then rejection process should continue otherwise rejection process should be stopped and raise an error message. So the approver can only reject with rejection reason.
Normally if we need to make Rejection reason as mandatory then you can check it in the BBP_DOC_CHECK_BADI by reading the long texts based on the GUID using the BBP_PD_SC_GETDETAIL. But here the requirement is to show a popup to enter rejection reason. We cannot raise popup from the BADI. So somewhere in the Webdynpro component level we have to call a popup.
But whenever approver clicks on the Reject button it’s running the actual rejection process logic and then related webdynpro components (Shopping Cart Header, Item, and Approval Note components) are triggering. So we cannot really create an enhancement to these Webdynpro components to raise popup, because the actually process is already happening.
We should be able to control the execution of Rejection process to execute after the popup shows. So we should execute a custom action instead of standard REJECT FPM action and based on the Rejection reason entered or not we should trigger an actual standard REJECT FPM action.
- Capture the Approver action on the screen (is it REJECT or any other action).
- If REJECT then display the popup to enter rejection reason. If the user entered reason and click on ok then close the popup and reject the cart with entered reason. If not then don’t close a popup and raise an error message. If the user click on CANCEL button on popup screen then close the popup and show an error message in main screen and don’t reject.
- If the action is not REJECT then don’t do anything just normal process should continue.
Enabling Approve & Reject buttons at Approval Screen
Generally approval screen will be like below. We don’t find approve & Reject buttons in the screen and instead submit button will be there. In this case you can approve some items and reject some items. So Item level approvals are there.
But here, our case is total document approve and we don’t have item level approvals. So we have to hide submit button and 2 columns (Approve/Reject). And enable Approve & Reject buttons on the approval screen. Approve button approves total document and Reject button Rejects total document.
We cannot directly enable the Approve & Reject buttons through FPM configuration editor. Because those buttons visibility is controlling somewhere in the run time. Even those you enabled the Approve & Reject buttons those won’t be displayed there. So we have to enable those dynamically.
We should also make sure the Approve & Reject buttons only visible for approval screen and not in the creation and edit of Shopping cart screen. To achieve this we can create an enhancement to Webdynpro component /SAPSRM/WDC_UI_SC_OIF_CA and create a Pre-Exit for WDDOMODIFYVIEW method of view V_SC_OIF_CA.
Place this V_SC_OIF_CA->WDDOMODIFYVIEW section of code in attached document.
Capture Approval Action (is it REJECT or any other action)
We have an option to Approve/Reject the Shopping cart from 2 different screens. I mean, Approver can Approve/Reject directly from the UWL or go to the details (By clicking on the Shopping Cart or Details button) and Approve/Reject from there.
So we have to capture the action from both screens and also we have to know from which screen it’s triggered.
We cannot capture both actions at one place, because UWL action won’t trigger the Webdynpro components and details screen can be captured at Webdynpro. So we have to find a place to capture those.
We are going to capture these actions using the Export/Import Memory statements
Details Screen Action
You can capture details screen actions at /SAPSRM/CL_CH_WD_MAP_IDENT_SC->/SAPSRM/IF_CLL_IDENT_MAPPER~HANDLE_EVENT this method.
Attached document has code.
UWL Screen Action
You can capture UWL screen actions at FM /SAPSRM/FU_WF_RFC_DECISION.
Attached document has code.
Validation and Display popup for Rejection Reason
Details Screen Rejection
Here we are calling standard approval note popup view as our Rejection reason popup. We are not creating any new view and the component for Approval note /SAPSRM/WDC_DO_APPR_NOTE.
As shown in the below screen, the approver should enter Rejection reason in the Approval Note. Any notes will be entered here by Approvers and Requesters. If there are no notes then you can directly enter in the below shown input box.
If there are some notes already there then you will see Add Comment link option to add new note. If you click on that then a popup will be displayed to enter the notes. Those notes will be prefixed to the previous notes with User & timestamp.
The Approval Note popup will be shown like this.
Here now if we need to achieve our functionality.
- First we have to find type of action (REJECT or any other action)
- If the action is not REJECT then normal process should happened like Approve, Check, etc.
- If the action is REJECT then we have to fine whether approver entered an rejection note or not
- If approver entered a rejection note then rejection process should happened and the document should be rejected.
- If approver not entered a rejection note then we have to show popup to enter rejection reason. The process should go further if the user only enters a rejection note otherwise it should be stopped and raise an error message.
Here we are calling the same standard approval popup as rejection note popup when REJECT action triggered and no approval note.
So we have to check the above conditions and call popup in the Post-Exist of WDDOMODIFYVIEW in the V_DODC_MAIN_VIEW of
Place this attached V_DODC_MAIN_VIEW->WDDOMODIFYVIEW section of code.
This is view which is calling as popup for approval note and rejection reason.
Here we have to enhance the follow methods
- WDDOMODIFYVIEW – here we have to enable approval note input field to editable and other related operations. Here we are also calling the save action of popup view directly, because the rejection reason is already there so we should not display the popup. The same thing we can control in the popup calling view V_DODC_MAIN_VIEW but we have some problem raising FPM standard event from there. So we are calling the popup and automatically adding that without user action.
2) ONACTIONON_SAVE – Here we have to add the entered rejection text to document. First check action type if the action type is rejection then check the rejection reason entered or not. If not entered then don’t close the popup and show error messages. If entered then capture the entered rejection reason and raise a standard FPM REJECT event.
Remember we have changed the standard REJECT event with ZREJECT event and based on the condition we are raising standard Rejection event.
Attached document has this section of code V_DODC_ADD_COMMENT->ONACTIONON_SAVE
3) ONACTIONON_CANCEL – Here we have to close the popup and stop the process by raising an error in the main screen.
Attached document has the code V_DODC_ADD_COMMENT->ONACTIONON_CANCEL
4) BBP_DOC_CHANGE_BADI – Here we are going to update the approval note to document.
Attached document has the logic
UWL Level Rejection
For UWL action we don’t have an option to raise a popup directly. We may have to include that in workflow step to show popup.
But here I am just raising an exception in the BBP_DOC_CHECK_BADI with some text saying
“Please click on details and enter Reason for Rejection in Approval Note Fiel”
DATA: lv_id3 TYPE c LENGTH 15 VALUE ‘UWL_ACTION’,
lv_uwl_action TYPE /sapsrm/cll_decision,
* Import UWL Screen Action(Approve/Reject)
IMPORT p2 = lv_uwl_action FROM MEMORY ID lv_id3.
** If Document is Shopping Cart
IF flt_val = ‘BUS2121’.
* And Action is UWL then Rasie the Exception with below text and stop the Rejection
IF lv_uwl_action = ‘REJECTED’.
MESSAGE ‘ – Please click on details and enter Reason for Rejection in Approval Note Field’ TYPE ‘E’.
** End of – SMARAPUREDDI – July/29/2014 Reason for SC Rejection UWL Validations