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.
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
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.
You can capture UWL screen actions at FM /SAPSRM/FU_WF_RFC_DECISION.
Attached document has code.
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.
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
/SAPSRM/WDC_DO_APPR_NOTE.
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
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
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'.
ENDIF.
ENDIF.
** End of - SMARAPUREDDI - July/29/2014 Reason for SC Rejection UWL Validations
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.