User decision with automatic note
Recently I was able to put my hands on a ECC 6.0 Ehp6. I read about the new functionalities available on SAP Business WF since the last year and I was curious to understand something more about the development described in note 1643764 – User decision with automatic note (available only via support package).
SETUP
I created a WF with three decision steps and the container element
The first question is “Can I write a note ?”
Note the “Justification” column in the Decision Option table. In this field you can decide if the note is “Required”, “Mandatory” or not needed for a specific alternative. In the Control tab, the binding is set as follow
The second decision is “Can I change a note ?”
In the Control tab, the binding is set as follow
The third question is “Does it work ?”.
Running the WF…
this is what you get.
If you answer “No” the WF goes on without asking anything. If you click on “Yes, you must” (note is mandatory) a pop up appears
If you press “Cancel”, you go back to the decision. If you press “Continue” without writing anything in the text box you get the error “Create a reason for the selected alternative”. If you specify a text and press continue, the WF goes on to the next question.
If, in the decision step, you click on “Yes” (note required) the same pop up appears but if you click on “continue” without writing anything, the WF goes on to the next activity.
Assuming we just wrote a note, this is the way the second question appears :
The previous note is shown as an attachment. The button “Create reference” is available in the tool bar (as a consequence of the binding defined in the WF). The right answer to the question is “No” but the button “Create reference” let you use an existing note as a template. You can update the message and save it as a new WF document (actually, this is not a new functionality).
Clicking on “No” the WF propose the last question… “Does it work ?”
Well, from a technical perspective the answer is “Yes”. It’s quick, easy to understand and easy to develop but I can’t swear that my customers will appreciate it as I do….
This is great, Gianluca! I haven't had a chance to explore this new functionality myself, so I am glad you have - and even better that you are sharing it with the gang.
Keep on blogging!
Sue
Thanks for this blog Gianluca. I would like to know more about this feature but I can't see it mentioned in any of the release notes. I specifically want to be able to call the workflow decision step from an external program. Do you have any references for where I can find out more?
Cheers
Graham Robbo
Hi Graham, thank you for your feedback. I focused my attention on this topic reading Susan's blog but I was not able to find out more anywhere else (that's why a wrote this blog). About the chance to execute a decision task from an external program, I usually create my custom WFs, managing this issue with parallel branches and events in the workflow design. Anyway you can read the decision WI detail calling the FM SWU_GET_DECISION_TEXT_TITLE (but it's not RFC enabled), so you should be able to provide the decision alternatives in your external interface. I can't tell you exactly how to set a decision WI as executed, I should execute some test. Maybe it's a chance for a new blog.
Thank you again,
Gianluca
Thanks Gianluca, I spent a few hours yesterday hacking through this. I have found the code that does this but unfortunately it is not exposed by the SAP workflow API's (WAPI's). This is very disappointing and something I hope SAP will rectify soon.
The system I was using is running Ehp6 with NetWeaver 7.31 SP 5. The relevant code is in the function group SWU2 which has a "TEST" status. All the function modules are marked "Not released" and several include "INTERN" in the name which to me means "SAP Internal".
The storing of the note, attaching it to the workitem, and executing the workitem decision all occur in the same LUW. Also the container item attribute name is hardcoded to 'DECISION_NOTE'.
All this leads me to believe - and hope - that there is more to come.
Cheers
Graham Robbo
Good blog Gianluca!
Graham, were you not able to use SAP_WAPI_DECISION_READ or SAP_WAPI_DECISION_COMPLETE? The read should at least have worked to return the available decisions in a remote enabled format.
Also SAP_WAPI_READ_CONTAINER and SAP_WAPI_WRITE_CONTAINER are available to adjust the container, which you could call before completing the decision.
Curious to know what the difficulty was... It would be worth raising a SAP Message for this if you can't support it using the standard WAPIs.
Regards,
Jocelyn
Hi Jocelyn,
sorry I have been distracted by Sapphire for a bit and didn't respond to this quickly.
The issue(s) I found were that the returned data structures from SAP_WAPI_DECISION_READ have not been extended to include the "justification" field. So there is no way to tell if a note is "required" or "mandatory" for a decision path using the available WAPI calls.
Additionally after the creation of the note, the subsequent attachment to the workflow container and the execution of the decision are done in a single unit of work. Again there is no WAPI available to do all this in a single call - which to my mind there probably should be. Sure I can manipulate the container myself to achieve the same outcome - but should I have to if I am a non-SAP external application?
Cheers
Graham Robbo
Hi Graham
Well its worth asking for an extended WAPI to go with the extended functionality. There is already a WAPI for the attachment but I agree it would make sense to have a consilidated WAPI
Thanks for sharing this. This functionality was pending for very long time. It would have been better if the note section would have been shown in a way where you can see all the comments at one go with previous ones being disabled. Sort of history or log of comments rather than creating a new attachment each time.
What do you think?
Regards
Nabheet
Thank you for your feedback. I'm agree with you. Technically it works fine but from user experience perspective it's not so fascinating. It may also leads to an explosion of attachments. To be honest, I don't think it will lead to a revolution in our developments but it's a beginning.
Regards,
Gianluca
Hi Giamluca,
Thanks the lot for providing this new functionality very briefly with screen shot.
Keep Blogging more and more for knowledge sharing my friend. 🙂 🙂
Any way once again Thanks.
Warm Regards,
Ragav
hi Gianluca,
thats cool. I seldom get chance to build WF these days!!!
I wish if someone could post more such blogs or one blog with all new features that SAP Workflow has with SAP's recent enhancements.
Like the one you posted on User Decision Step, BRFPlus option, etc...
Nice blog.
Thanks,
Aditya V
Good blog Gianluca. i have some questions here if you can help.
I am on SAP_BASIS 702 SAPKB70209 and understand that the note 1643764 is implemented. However my confusion is on decision task because when i check standard decision task I don't see parameter decision_note in container which won't allow the binding.
does it mean that i need to create decision_note field manually in the decision task too?
thank you for throwing light on the remarks field as this is very common requirement of each customer across the globe.
regards
barin
Hi Barin,
for what is my understanding, you don't need to modify anything on the standard user decision task. I got some trouble with the custom ones. According to the note they have to be enhanced manually. I'm far from my office with limited access to my systems, as soon as i'm back, I'll try to be more detailed.
Regards,
Gianluca
Hi Gianluca
thank you for responding.
however following is the answer.
1. As you said we need to add decision_note parameter in the workflow task if we are on right SAP-BASIS patch.
Patches are provided in the note and I managed to get the answer to all queries I wanted.
Very informative blog and thank you for the details.
regards
barin
Hi Gianluca
I have one more question.
What would be the impact if this task is used from Universal worklist. I am sure we will have to make some changes to assure the the decision_note parameter is moving from the UWL xml to the workflow/ task container.
Any advise on this?
regards
barin
Hi Barin,
I believe you will still need to adjust the uwl xml for your User Decision - try this link for more info.
UserDecisionHandler (SAP Library - Business Task Management)
Hope that helps
Jocelyn
Hi,
Hope to behave the same way in CRM WebClient UI. (Release 731)
SAP Said That the requested functionality is not available in the standard.
Somebody solved the issue.
regards
Carlos
Thanks Gianluca for clearing this up. I've always been confused between 'required' and 'mandatory' since they somehow mean the same. From my understanding, 'required' means 'optional' and 'mandatory' means 'required/mandatory/obligatory'.
Anyway, I have used this functionality in my previous assignment and it works as designed. The only issue I had was when I tried to combine this functionality with dynamic user decision. It didn't work when I have one of the options deleted from the user decision in the user exit.
For e.g. I have 3 options for 3 levels of approvers:
1. Approve
2. Reject - (justification: mandatory)
3. Acknowledge
but only 2 options for the last approver:
1. Approve
2. Reject - (justification: mandatory)
In the loop step, the first 3 approvers may approve or reject (which will complete the workflow) or acknowledge (which will proceed to the last approver). The last approver have to approve or reject (with mandatory rejection note).
So in the user exit (in the loop step), I'm checking for the last approver so I can delete the 3rd option in the dynamic decision. The problem is, when this is executed, the mandatory decision note disappeared in the workflow, meaning if the approver selects 'Reject' there's no popup screen to enter the rejection note anymore.
Because of this issue and time constraint, I had to abandon the dynamic user decision functionality and used a condition step to create 2 separate user decisions based on the approver level. If anyone else has the same issue, I would like to know the solution.
Thanks.
Thanks for the information.
It was totally helpful!
Regards.
Danilo
I have a small concern here:
This is ideally how I would read the reason entered in the popup:
* 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.
Explicit code was written to remove the 1st five characters from the rejection reason. This is because the length gets captured when rejecting from SBWP. However, when rejecting from Fiori Inbox, the length is not being captured as a result, the text is being truncated. Any thoughts on this?
am very glad to you
you saved me
i have spent lot of time searching about your code
many thanks for you
Thanks for the great blog. In case anyone wants to use the rejection reason for further processing, Function Module SAP_WAPI_DECISION_COMMENT returns the rejection reason.
Happy coding!