Creating Method to Execute Work Items Together (BOR)

Use

The Workflow Inbox gives you the option to mark several work items and execute them together. Here you only execute the first work item. All other work items are executed by the workflow system in the same way as the first work item. For example, you can approve several leave requests at the same time whereby you only approve the first one and those remaining are selected by the workflow system.

For you to be able to use this function in the Business Workplace, the work items selected must fulfill the following prerequisites:

  • The method with this task must be executable synchronously.

  • The method must have exactly one export parameter or one result parameter which contains the result of the first method execution.

You must insert the sections of the example program that are colored and highlighted by the NEW comment in an existing implementation program of a method, so that work items for this method can be executed together.

Example

Work items that refer to the Approve method of FORMABSENC object type can be executed together. The PROC_STATE parameter is marked as the result parameter.

begin_method approve changing container.
DATA: proc_state LIKE swxformabs-procstate,
      return_code LIKE sy-subrc,   
      multiexec_item   TYPE REF TO if_swf_utl_multi_exec, "NEW
      multiexec_status TYPE swumexesta                    "NEW

CALL METHOD cl_swf_utl_multi_exec=>create                 "NEW
    IMPORTING                                             "NEW
      ex_if_ref = multiexec_item.                         "NEW

CALL METHOD me_item->get_status                           "NEW
    RECEIVING                                             "NEW
       re_me_status = multiexec_status.                   "NEW

CALL FUNCTION 'SWU_OBJECT_PUBLISH'
    EXPORTING
       objtype = 'FORMABSENC'
       objkey  = object-key.

IF multiexec_status <> multiexec_item->c_me_auto.         "NEW

CALL FUNCTION 'SWX_FORMABS_APPROVE'
    EXPORTING
      formnumber     = object-key-number
    IMPORTING
      proc_state     = proc_state
    EXCEPTIONS
      form_not_found = 01
      aborted        = 02.
return_code = sy-subrc.    " save the return code for later re-use
ENDIF.                                                    "NEW

CALL FUNCTION 'SWU_OBJECT_RESTORE'
    EXPORTING
      objtype = 'FORMABSENC'
      objkey  = object-key.

CASE return_code.
  WHEN 01.
    exit_return 1301 space space space space.
  WHEN 02.
    exit_cancelled.
ENDCASE.

CALL METHOD multiexec_item->update_result                 "NEW
    CHANGING                                              "NEW
      ch_wi_result = proc_state.                          "NEW
 
swc_set_element container result proc_state.

IF multiexec_status = multiexec_item->c_me_auto.          "NEW
   UPDATE swxformabs SET procstate = proc_state           "NEW
                     WHERE formnumber = object-key-number."NEW
  IF sy-subrc <> 0.                                       "NEW
* Form not found                                          "NEW
     exit_return 1301 space space space space.            "NEW
  ENDIF.                                                  "NEW
ENDIF.                                                    "NEW

end_method.