Capture Rejection Reason Text from User Decision in Workflow
By Anirban Bhattacharjee, KPIT Cummins and Infosystems from Link
Purpose: The purpose of this document is to capture the rejection reason text from the user decision step in workflow.
Business Scenario: When a user decision with the APPROVE and REJECT options are sent to the approver, there always comes a business need to allow the user to enter a “Rejection Reason” text, when the approver does a rejection. In the older SAP Releases, the standard User Decision step did not have a process to capture the rejection reason. The latest release of SAP includes this feature.
In this document we will see how to use this feature and capture the rejection reason text and also pass it to an e-mail sending step. This e-mail we can send to the original requestor so that he gets to know the cause of the rejection and resubmit for approval after the necessary corrections.
Process: This demo creation will involve the following steps
· Create a user decision step with APPROVE and REJECT options and model the Rejection Reason only for the REJECT Branch.
· Capture the rejection reason text and pass to an e-mail sending step via a container.
Pre-requisites: There are a few pre-requisites before doing this demo.
· You should know how to build a basic workflow with the send e-mail step and user decision step. (SAP Technical.Com already has these tutorials)
· SCOT and SAP Connect must be configured for e-mail sending.
· All other workflow configurations via SWU3 are already done.
· You know how to create methods in a custom BOR and call in workflows. (These will not be covered in details)
Create Custom Workflow and Method to read the REJECTION Reason for Demo
(Please read the tutorials on creation of Custom BOR/Method and Custom Workflow with user decisions and e-mail sending steps in SAP Technical.Com to get the details)
We create the user decision step and mark the two branches APPROVE and REJECTED as shown
Notice that in the latest SAP version, we have an option to configure the Rejection / Approval reasons.
You can use this for any reason you want as per the branch you have created.
We can mark the Reason as Mandatory or Required.
Mandatory: This means, that the Reason has to be mandatorily entered when the corresponding action is performed, else the user decision work item cannot be completed.
Required: This means, that entering the Reason is optional. The pop-up to enter the reason will appear, but it is not needed to enter anything to complete the work item.
Here we will mark this Reason as MANDATORY for our REJECT Branch as shown
The step is saved. When the user enters the Reason, it will get appended into the _Attach_Objects standard container of the workflow.
This multiline element points to the SOFM Business Object.
We will now write a method to read this attachment and transfer to a text string.
This method will be an instance independent method. This means, it can be called without instantiating the BOR.
The parameters for this method are shown below
The details of the parameters are
Parameter WORKITEMID:
Parameter REASON_TXT:
We will be passing the work item ID of the workflow and this method will read the container _Attach_Objects and pass the Rejection Text to variable REASON_TXT.
The code that you will write in the method is given below: (You can write your own code to read and process the SOFM Attachment Object as per your need)
begin_method read_rejection_reason changing container.
DATA: reason_txt TYPE swcont-value,
reason TYPE swc_object OCCURS 0,
object_content LIKE solisti1 OCCURS 0,
workitemid LIKE swr_struct-workitemid,
subcontainer_all_objects LIKE TABLE OF swr_cont,
lv_wa_reason LIKE LINE OF subcontainer_all_objects,
lv_no_att LIKE sy-index,
document_id LIKE sofolenti1-doc_id,
return_code LIKE sy-subrc,
ifs_xml_container TYPE xstring,
ifs_xml_container_schema TYPE xstring,
simple_container LIKE TABLE OF swr_cont,
message_lines LIKE TABLE OF swr_messag,
message_struct LIKE TABLE OF swr_mstruc,
subcontainer_bor_objects LIKE TABLE OF swr_cont.
swc_get_table container 'REASON' reason.
swc_get_element container 'WORKITEMID' workitemid.
* Read the work item container from the work item ID
CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
EXPORTING
workitem_id = workitemid
language = sy-langu
user = sy-uname
IMPORTING
return_code = return_code
ifs_xml_container = ifs_xml_container
ifs_xml_container_schema = ifs_xml_container_schema
TABLES
simple_container = simple_container
message_lines = message_lines
message_struct = message_struct
subcontainer_bor_objects = subcontainer_bor_objects
subcontainer_all_objects = subcontainer_all_objects.
* Initialize
lv_no_att = 0.
* Read the _ATTACH_OBJECTS element
LOOP AT subcontainer_all_objects INTO lv_wa_reason
WHERE element = '_ATTACH_OBJECTS'.
lv_no_att = lv_no_att + 1.
document_id = lv_wa_reason-value.
ENDLOOP.
* Read the SOFM Document
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = document_id
TABLES
object_content = object_content.
* Pass the text to the exporting parameter
IF sy-subrc = 0.
READ TABLE object_content INTO reason_txt INDEX 1.
SHIFT reason_txt BY 5 PLACES LEFT.
swc_set_element container 'REASON_TXT' reason_txt.
ENDIF.
end_method.
Note that the method we created, READ_REJECTION_REASON can be executed even without instantiating the BOR
The above method will be called in a standard task and called in the REJECT branch of the user decision step.
The standard task will look like as shown below
The binding in this standard task
The binding in the workflow to this task is shown as below
Predecessor work item will contain the Work Item ID of the User Decision Step.
The user decision step is just the previous step to this background step in this workflow template.
The workflow will look like as shown below after adding the above step in the REJECT branch of the User Decision
Now we will create an e-mail step after this “Read Rejection Reason Text”. Here we will pass our text and send as an e-mail.
For simplicity of the demo, I will be hard-coding a dummy e-mail ID to the send e-mail step.
After this process, the complete workflow template will look as shown below
We have not modeled anything for APPROVED branch, since we are show casing only the Rejection Reason.
You can model the Approve or any other branch as per your business need.
We are now ready to test the workflow.
We will run transaction SWUS to test the workflow
We run the user decision from business workplace SBWP
Now select REJECT to process rejection. Normally the work item would get completed here, but the system will generate a POP-UP to prompt for the Reason.
This pop-up will appear due to our configuration. We enter the REJECTION Reason text and press OK
(Please note, if you cancel this POP-UP, the work item will still remain in your inbox and not get completed. This is because we marked the Reason as MANDATORY)
Looking at the workflow log, we can see that the element _ATTACH_OBJECTS (Attachments) contains the SOFM entry
Now looking at the e-mail step in the log, we will check the task description to see if our text is captured
You can see the Rejection Reason is captured. We can see this in the container also
Now running the SOST transaction to see if the same appears in the e-mail body as well
So we have successfully captured the REJECTION REASON TEXT and displayed it in the e-mail body.
You can use this functionality in multitude of other ways as per your business need in your project.
相关推荐
《Power Supply Rejection Ratio in Operational Transconductance Amplifiers》这篇文章由IEEE出版,是关于运算跨导放大器(Operational Transconductance Amplifiers,简称OTAs)中的电源抑制比分析的经典文献。...
basic premises in the existing paradigms, from which it is argued that a paradigm shift is necessary. Using a motion control metaphor, the basis of such a shift, the Active Disturbance Rejection ...
Power supply noise rejection (PSNR) is a measurement of how well a circuit rejects noise from various frequencies which are coupled into the power supply. In actual high speed analog and digital ...
这一现象被称为“掌部误触”(Palm Rejection)。本文将详细介绍电阻式触摸屏中的掌部误触问题,并探讨其解决方案。 #### 二、掌部误触概述 掌部误触是指在使用笔或触控笔在触摸屏上书写或绘画时,由于手部其他...
邻道抑制比(Adjacent Channel Rejection, ACR)是衡量射频接收器性能的一个重要参数,它主要描述了无线接收器在频谱上抑制相邻信道信号的能力。良好的ACR性能意味着接收器能够在接收目标信道信号的同时,有效地抑制...
第一章介绍了自抗扰所能处理的非线性系统,第二章是跟踪微分器的收敛性证明,第三章是扩张状态观测器对各种非线性系统的收敛性证明,第四章讨论基于TDESO的反馈闭环系统的收敛性,第五章是ESO及其下三角系统...
Clutter Rejection Technique for FLIR Imagery
关键词包括风能转换系统(Wind Energy Conversion System)、永磁同步发电机(Permanent Magnet Synchronous Generator)、最大功率追踪(...MPPT)、自抗扰控制器(Active Disturbance Rejection Controller...
In rough set theory, a decision class (i.e., a subset of objects) is approximated by three pair-wise disjoint positive, boundary, and negative regions. The concept of three-way de- cisions is ...
A defect layer is introduced in the periodic high/low index layers in the cladding of the Bragg fiber, which results in large confinement loss for some resonant wavelengths inside the band gap range ...
Juvenile delinquency in relation to peer acceptance-rejection and socio-economic status JUVENILE DELINQUENCY IN RELATION TO PEER ACCEPTANCE- REJECTION AND SOCIO-ECONOMIC STATUS’ MERRILL ROFF A N...
Optical frequency shift keying (FSK) homodyne detection utilizing image rejection in FSK/amplitude shift keying (ASK) re-modulation wavelength-division-multiplexed passive optical network (WDM-PON) is...
安装 $ npm install loud-rejection用法 const loudRejection = require ( 'loud-rejection' ) ;const promiseFunction = require ( 'promise-fn' ) ;// Install the `unhandledRejection` liste
The requirement of the rejection floor level in the wavelength filter was clarified to achieve the ultimate spectral efficiency in DWDM systems. A cascaded filter can satisfy this condition.
The rejection of that last good-bye kiss became a poignant memory, especially after his father's passing. He now regrets his decision to reject his father's love and wishes he could have that moment ...
Physically Based Rendering from Theory to Implementation 一共3部分~~~~~~~~~, 源码下载to h t t p ://www.p b r t . o r g /downloads.php /////////////////////////////////// CHAPTER 01. ...
Unhandled rejection SequelizeAccessDeniedError: Access denied for user 'lupeng'@'localhost' (using password: YES) 这是Node在使用Sequlize连接Mysql数据时报的错,关键看冒号后面的错误:访问拒绝,关键是...