cancel
Showing results for 
Search instead for 
Did you mean: 

Mass approval scenario for Workflow.

Former Member
0 Kudos

Hi All,

This is my first post on SCN.

I'm currently having a  requirement to implement mass approval for employee work list.

There will be 2 buttons added in the portal - approve/ reject.Once the user logs in and selects the appropriate task's he should be able to approve or reject these in one go.

Please forward me any documents in this regard.

Thanks in advance!

Regards,

Chandni

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi All,

Thanks for all your inputs.

Below is the section of code developed.

   *--READ THE CONTAINER VALUE FOR PROCSTATE, IF PRESENT IN THE CONTAINER.
    CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
      EXPORTING
        WORKITEM_ID      = IV_WORKITEM_ID
      IMPORTING
        RETURN_CODE      = ev_sysubrc_read
      TABLES
        SIMPLE_CONTAINER = lt_simple_container_read.

    clear lt_simple_container_read.

    READ TABLE lt_simple_container_read WITH key ELEMENT = 'PROCSTATE' .

    IF sy-subrc eq 0."--> sy-subrc for the above read statement
      lv_tabix = sy-tabix.

*--CHANGE THE CONTAINER VALUE BASED ON USER DECISION.
*--check for user decision and set the PROCSTAT value for workitem container.
      if IV_ACTION_TAKEN = 'X'" Approval action taken on the workitem
        lt_SIMPLE_CONTAINER_read-value = 'APPROVED'.
      elseif IV_ACTION_TAKEN = ' '.
        lt_SIMPLE_CONTAINER_read-value = 'REJECTED'.
      endif.

      MODIFY lt_SIMPLE_CONTAINER_read INDEX lv_tabix.

*--Change the value of the container based on the above set value

      CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'
        EXPORTING
          WORKITEM_ID      = IV_WORKITEM_ID
          DO_COMMIT        = 'X'
        IMPORTING
          RETURN_CODE      = ev_sysubrc_write
        TABLES
          SIMPLE_CONTAINER = lt_SIMPLE_CONTAINER_read.

      if ev_sysubrc_write = 0.
*--COMPLETE THE WORKITEM BASED ON THE USER DECISION/VALUES MAINTAINED AT PORTAL LEVEL
*=> The workitem moves to the next level

        CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'
          EXPORTING
            WORKITEM_ID      = IV_WORKITEM_ID
          IMPORTING
            RETURN_CODE      = ev_sysubrc1
            NEW_STATUS       = ev_new_status
          TABLES
            SIMPLE_CONTAINER = LT_SIMPLE_CONTAINER_COMPLETE.
        commit work AND WAIT.
      endif.
    else.
*-- if the process state is not present in the container, then leave!
      exit.
    ENDIF.

  ENDIF.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Murali,

thanks for your quick response.

The requirement is that from portal, when a manager logs in he should be able to approve/ reject pending worklists in one go.

That is from portal end, we receive - work item Id, task Id and the action taken from the manager- that is approval or rejection.

I understand that we may need a RFC in this regard, which takes up these 3 parameters as the input parameters.

Depending on the action taken we may need to update the database using the FM

SAP_WAPI_DECISION_COMPLETE.

However, I'm still confused with the usage of SAP_WAPI_DECISION_COMPLETE.I tried executing the FM with the dummy parameters, but i'm not quite sure wheter this is the correct FM used to update the database, with the action taken up by the manager.

Regards,

Chandni

Former Member
0 Kudos

Hi Muni,

We can use the RFC FM's for retrieving the Work Item ID, to change and read the Task Container Elements, to complete or cancel the Work Item etc.

The following FM's are used to process the workitems according to the user decision.

*Fetch the work item id of parent of the current work item
           SWP_TOP_LEVEL_WORKFLOW_GET

*To read work item ID and to read container values of the workflow header for current work item
           SAP_WAPI_READ_CONTAINER

*Change Task Container

           SAP_WAPI_WRITE_CONTAINER

*Trigger Event on user submit or approve

           SAP_WAPI_CREATE_EVENT

*To complete the decision

           SAP_WAPI_DECISION_COMPLETE

*To cancel the work item

           SAP_WAPI_ADM_WORKFLOW_CANCEL

The following links may help you regarding FM SAP_WAPI_DECISION_COMPLETE.

http://scn.sap.com/docs/DOC-41785

http://scn.sap.com/thread/1428647

Regards,

Murali.

former_member186746
Active Contributor
0 Kudos

Hi,

If you want to solve the requirement in this way then this is the correct function module to use.

Alternatively you could use terminating events to proceed to the next level in your workflow.

Personally I would use events for these kind of requirements, I don't like fiddling directly with the workflow.

Kind regards, Rob Dielemans

Former Member
0 Kudos

Hi,

Create a workflow with the following steps

1. Fetch the agent

2. Send a mail to the agent with Accept & Reject options

May be the following link will help you,

http://scn.sap.com/people/dheerendra.shukla/blog/2009/09/14/massbatch-processing-of-work-items-in-uw...

Regards,

Murali Krishna.