Skip to Content
avatar image
Former Member

Approve or Reject using Function Module

Hi ,

I want to approve or reject the workitem using UI5. The backend process is already set it has workflow for the same.

The workflow looks exactly like this : https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=68644

The Worlflow consultant have used the Form for approve or reject. Now I want achieve this using the FM : SAP_WAPI_DECISION_COMPLETE

But the issue is when I pass the workitem ID to this FM it say that it don't have decision key.

Kindly suggest a way where I can Approve or Reject using Function Module.

Thanks

Vishal

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Apr 26, 2017 at 07:13 AM

    Hi,

    To use the function module SAP_WAPI_DECISION_COMPLETE two things are very important to understand

    1. The work item which you are trying to complete is a standard decision step, or is it is a copy of TS00008267 , or it is the same task.
    2. You must be aware of the action option sequence define in the decision step of the workflow. For instance 001 is for Approve, 002 is for Reject.
       CALL FUNCTION 'SAP_WAPI_DECISION_COMPLETE'
     EXPORTING
     workitem_id = i_wiid
     language = l_langu
     user = l_uname
     decision_key = <PASS the ID  it can be either 001 or 002> 
     do_commit = 'X'
     IMPORTING
     return_code = l_subrc
     TABLES
     message_lines = lt_message_lines
     message_struct = lt_message_struct.

    Form step of the workflow does not use the decision step task it is generated dynamically each time you create a new form step. So this function module does not work.

    Thanks, Pavan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 26, 2017 at 08:09 AM

    Thanks Pavan ,

    Yes, Pavan you are right is is not a decision step.Instead they call a module pool in that module pool the user takes the decision.

    If you go through this link : https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=68644

    you will get a correct idea.

    Can u please suggest how can I achieve this using function module.

    Thanks,

    Vishal

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 26, 2017 at 10:04 AM

    Hi ,

    You can try the below approach may be if it works for you

    first try to set the values in the workitem container which helps to decide whether they approved or rejected by using SAP_WAPI_WRITE_CONTAINER.

    secondly, then try to execute the workitem by usinf SAP_WAPI_EXECUTE_WORKITEM or SAP_WAPI_WORKITEM_COMPLETE.

    Thanks, Pavan

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Pavan,

      I will try by your way.I want to approve or reject through UI5.

      Can u pls let me know how can I pass the decision key in FM : SAP_WAPI_WORKITEM_COMPLETE.

      Regards,

      Vishal

  • Apr 26, 2017 at 10:23 AM

    Hi,

    From my suggestion, change the workflow design. You can add deadline monitoring in the Form step, if user not execute it, then delete the step and in modelled deadline you add step to your desire functionality

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Anjan,

      But changing the workflow is not an option for me right now.

      Thanks for your input.