Redefine method EXECUTE_ACTION

This method is executed in the implementation class whenever an action is triggered by a decision task by the user in OneList.

The actions are configured in OneList and can be used to represent approval decisions made by the user for a specific task for example Approve, Reject, Return, etc. 

Method Parameters

Type

Name

Description

Type

Name

Description

Importing

ID_TASK_ID

OneList Task ID being actioned (SAP workflow work item ID)

Importing

ID_ACTION_BY

User Name that triggered the action

Importing

ID_ACTION_ID

OneList Action ID

Importing

ID_ACTION_COMMENT

Action comment entered by the user in OneList

Importing

ID_OBJECT_ID

The object ID of the workflow task (generally, the SAP document number being actioned)

Exception

FAILED_TO_ACTION

Raised exception when the action could not be executed

Method Implementation

Custom ABAP logic can be implemented using the import parameters sent by OneList to execute the desired action outcome in SAP. 

As an example, the Release and Reject actions for a Purchase Order approval can be implemented as follows:

METHOD execute_action. DATA: lo_api TYPE REF TO cl_gbapp_apv_po_api. DATA: lt_approval_decision TYPE gbappt_po_approval_decision, ls_approval_decision TYPE LINE OF gbappt_po_approval_decision, ls_parameter TYPE LINE OF /iwbep/t_mgw_name_value_pair, lt_parameter TYPE /iwbep/t_mgw_name_value_pair, ls_action_result TYPE gbapps_action_result. DATA: ld_po_number TYPE bapimmpara-po_number, ld_rel_code TYPE bapimmpara-po_rel_cod. ld_po_number = id_object_id. ld_rel_code = me->get_po_rel_code( id_po_number = ld_po_number ). lo_api = cl_gbapp_apv_po_api=>get_instance( ). CHECK ld_rel_code IS NOT INITIAL. CLEAR ls_approval_decision. CLEAR lt_approval_decision. ls_approval_decision-workitem_id = id_task_id. CASE id_action_id. WHEN 'RELEASE'. ls_approval_decision-decision = '0001'. ls_approval_decision-approval_text = id_action_comment. WHEN 'REJECT'. ls_approval_decision-decision = '0002'. ls_approval_decision-rejection_text = id_action_comment. ENDCASE. APPEND ls_approval_decision TO lt_approval_decision. TRY. lo_api->set_decision( EXPORTING it_approval_decision = lt_approval_decision IMPORTING es_action_result = ls_action_result ). CATCH /iwbep/cx_mgw_busi_exception . RAISE failed_to_action. ENDTRY. ENDMETHOD.

Below are other sample implementations that cater to various OneList decision workflows.

Standard Decision Task

METHOD execute_action. * Call default OneList action via Decision Task DATA: lv_wi_id TYPE swr_struct-workitemid, lv_new_wi_status TYPE sww_wistat, lv_return_code LIKE sy-subrc, lt_message_lines TYPE TABLE OF swr_messag, lt_message_struct TYPE TABLE OF swr_mstruc, ls_container_simple TYPE swr_cont, lt_container_simple TYPE swrtcont, lv_status TYPE tim_req_status, lv_decision_key TYPE swr_decikey, lv_decision_note TYPE swrsobjid, lv_rc TYPE sy-subrc, lv_comment_str TYPE string, lv_comnam TYPE text255 VALUE gc_comnam, lwa_return TYPE bapiret2, lv_newstat TYPE sww_wistat, lt_msglines TYPE STANDARD TABLE OF swr_messag, lt_msgstruct TYPE STANDARD TABLE OF swr_mstruc, lv_new_date_char(10), lv_new_date TYPE datum, lv_escalated TYPE flag, lv_must_be_after TYPE dats. FIELD-SYMBOLS: <lfs_msglines> TYPE swr_messag, <lfs_msgstruct> TYPE swr_mstruc. CLEAR: lv_new_date, lv_new_date_char. lv_wi_id = id_task_id. lv_decision_key = id_action_id. lv_decision_note = id_action_comment. CALL FUNCTION 'SAP_WAPI_DECISION_COMPLETE' EXPORTING workitem_id = lv_wi_id user = id_action_by decision_key = lv_decision_key decision_note = lv_decision_note IMPORTING return_code = lv_rc new_status = lv_newstat TABLES message_lines = lt_message_lines message_struct = lt_message_struct. IF lv_rc IS NOT INITIAL. READ TABLE lt_message_lines INDEX 1 ASSIGNING FIELD-SYMBOL(<message>). MESSAGE ID zcacl_ol_scenario_adpt=>gc_message_id_error TYPE <message>-msg_type NUMBER zcacl_ol_scenario_adpt=>gc_message_no_error WITH <message>-line RAISING failed_to_action. ENDIF. ENDMETHOD.

HCM Task

METHOD execute_action. DATA: lt_messages TYPE hrasr_return_tab, lt_attachments TYPE hrasr00attachment_tab, lt_form_field_values TYPE hrasr_special_param_tab, lt_input_help_values TYPE hrasr_special_param_tab, lt_field_ui_attributes TYPE hrasr_uiattribute_param_tab, lt_events TYPE hrasr00form_events_tab, lt_link_lists TYPE hrasr00link_tab, lt_history_details TYPE hrasr00step_attributes_ui_tab. DATA: lv_event TYPE syucomm, lv_ok TYPE abap_bool, lv_wi_id TYPE swr_struct-workitemid, lv_notes TYPE hrasr_s_special_param-fieldvalue. lv_wi_id = iv_task_id. lv_notes = iv_action_comment. lv_event = if_hrasr00_ui_constants=>c_event_initialize. " First, initialize CALL FUNCTION 'HRASR_PROCESS_EXECUTE' EXPORTING iv_wi_id = lv_wi_id iv_event = lv_event IMPORTING ev_is_ok = lv_ok et_messages = et_messages CHANGING ct_attachments = lt_attachments ct_form_field_values = lt_form_field_values ct_input_help_values = lt_input_help_values ct_field_ui_attributes = lt_field_ui_attributes ct_events = lt_events ct_link_lists = lt_link_lists ct_history_details = lt_history_details. IF lv_ok EQ abap_false. RAISE failed_to_action. ENDIF. * Prepare notes IF lv_notes IS NOT INITIAL. TRY. lt_form_field_values[ fieldname = gc_hrasr_current_note ]-fieldvalue = lv_notes. CATCH cx_sy_itab_line_not_found. INSERT VALUE #( fieldname = gc_hrasr_current_note fieldvalue = lv_notes ) INTO TABLE lt_form_field_values. ENDTRY. ENDIF. CLEAR lv_ok. CASE iv_action_id. WHEN gc_ol_action_id_approve. "APPROVE lv_event = if_hrasr00_fpm_constants=>c_event_approve. WHEN gc_ol_action_id_reject. "REJECT lv_event = if_hrasr00_fpm_constants=>c_event_reject. WHEN gc_ol_action_id_back. "BACK lv_event = if_hrasr00_fpm_constants=>c_event_backto. WHEN OTHERS. ENDCASE. CALL FUNCTION 'HRASR_PROCESS_EXECUTE' EXPORTING iv_wi_id = lv_wi_id iv_event = lv_event IMPORTING ev_is_ok = lv_ok et_messages = et_messages CHANGING ct_attachments = lt_attachments ct_form_field_values = lt_form_field_values ct_input_help_values = lt_input_help_values ct_field_ui_attributes = lt_field_ui_attributes ct_events = lt_events ct_link_lists = lt_link_lists ct_history_details = lt_history_details. IF lv_ok EQ abap_false. TRY. zhrcl_hrasr_ui5_connector=>wait_for_workitem_status( iv_wi_id = lv_wi_id iv_wi_stat = gc_wi_stat_completed ). "COMPLETED CATCH zcx_hrasr_ui5_exception. RAISE failed_to_action. ENDTRY. ENDIF. ENDMETHOD.

SRM Task