Skip to Content
SAP Environment, Health, and Safety Management

Automatic Phase Completion (Alternative to Structure Nodes) MOC 1.0 from FP1

Tags:

Applicable Releases:

MOC 1.0

IT Scenario:

Customer Enhancements

Table of Contents

  1. Scenario........................................................................................................................ 1
  2. Background Information................................................................................................ 1
  3. Prerequisites................................................................................................................. 1
  4. Step-by-Step Guide........................................................................................................ 2
  5. 4.1   IMG: Define Activity Type.................................................................................. 2
  6. 4.2   IMG: Define Activity Templates.......................................................................... 2
  7. 4.3   IMG: Define Notification Trigger........................................................................ 3
  8. 4.4   Enhancement: Enable re-opening of sub-activities............................................ 4
  9. 4.5   Workflow: suppress mail notification................................................................... 8
  10. 4.6   Application: Resulting behavior......................................................................... 9

 

1. Scenario

You would like to structure the activities into different phases or other groupings, where the completion of the sub-tasks are reflected in the status of the grouping node automatically. Prior to Feature Pack 1 (released June 2015), most customers would use activities of category ‘structure node’ for such groupings and since there was no means to update the status automatically after completion, some chose to suppress the status. This enhancement is described in a separate How-to-Guide.

Also, as of Feature Pack 1, it is possible to automate certain status changes based on IMG settings (“customizing”). This is an alternative to the suppression described in the above-mentioned How-to_Guide.

As of Feature Pack 1 you have the possibility to re-open activities. It should be noted that this functionality will not work, if a parent activity is in a final status. This guide includes an enhancement to enable the re-opening of activities, in spite of a phase node that has been auto-completed.

2. Background Information

The proposed solution consists of regular settings (IMG customizing and Workflow) and a customer-specific enhancement.

3. Prerequisites

Feature Package 1 (Support Package Stack 6).

4. Step-by-Step Guide

4.1 IMG: Define Activity Type

Define an activity type of category ‘notification’. Activities of this category have a status schema that is completed, once the notification has been sent: 

  1. In this example we call the type ‘Phase’. You could also call it ‘Structure Node’, but be sure to use category Notification.

4.2 IMG: Define Activity Templates

You can use this type in the same way, you use structure nodes. In this example we define a node for the evaluation phase using our new type Phase: 

We then insert the required task underneath – this could also be done rule-based via BRF+. 

4.3 IMG: Define Notification Trigger

On the Change Request type, register the new template for automated notification:

And add all activities that belong to that phase to the prerequisite activities: 

Note: In case of rule-based assignments, list all potential activities. The logic only takes activity instances into account that are in fact underneath the phase activity. In other words, a prerequisite activity listed here, that does not have an instance in a Change Request will not be checked for completion.

4.4 Enhancement: Enable re-opening of sub-activities

Open class /IAM/CL_V_ACT_CHECK_ACT_REOPEN in SE80 and create an enhancement. Then create an overwrite exit to method CHECK_CLOSED.

Copy the original method into the overwrite exit and adjust the coding, or copy it from here. Afterwards activate the enhancement.

CLASS LCL_Z_MOC_REOPEN_ACTIVITIES DEFINITION DEFERRED.

CLASS /IAM/CL_V_ACT_CHECK_ACT_REOPEN DEFINITION LOCAL FRIENDS LCL_Z_MOC_REOPEN_ACTIVITIES.

CLASS LCL_Z_MOC_REOPEN_ACTIVITIES DEFINITION.

PUBLIC SECTION.

CLASS-DATA OBJ TYPE REF TO LCL_Z_MOC_REOPEN_ACTIVITIES. "#EC NEEDED

DATA CORE_OBJECT TYPE REF TO /IAM/CL_V_ACT_CHECK_ACT_REOPEN . "#EC NEEDED

INTERFACES IOW_Z_MOC_REOPEN_ACTIVITIES.

  METHODS:

CONSTRUCTOR IMPORTING CORE_OBJECT

     TYPE REF TO /IAM/CL_V_ACT_CHECK_ACT_REOPEN OPTIONAL.

  1. ENDCLASS.

CLASS LCL_Z_MOC_REOPEN_ACTIVITIES IMPLEMENTATION.

METHOD CONSTRUCTOR.

ME->CORE_OBJECT = CORE_OBJECT.

  1. ENDMETHOD.

METHOD IOW_Z_MOC_REOPEN_ACTIVITIES~CHECK_CLOSED.

*"------------------------------------------------------------------------*

*" Declaration of Overwrite-method, do not insert any comments here please!

*"

*"methods CHECK_CLOSED

*" importing

*" !IS_CTX type /BOBF/S_FRW_CTX_VAL

*" !IT_KEY type /BOBF/T_FRW_KEY

*" !IO_READ type ref to /BOBF/IF_FRW_READ

*" exporting

*" !EO_MESSAGE type ref to /BOBF/IF_FRW_MESSAGE

*" !ET_FAILED_KEY type /BOBF/T_FRW_KEY

*" raising

*" /BOBF/CX_FRW .

*"------------------------------------------------------------------------*

**********************************************************************

*    To be able to re-open an activity we need to make sure that the

* parent activity and the parent issue are in an changeable state

*    The method checks if the parent activity and the parent change request

*    is not in a final or deferral state.

* final state of activities are:

*       - approved

*       - not relevant

*       - completed

* final state of issues are

*       - not applicable

*       - closed

* deferral state of issues are

*       - rejected

*       - on hold

*

* OVERWRITE EXIT CHANGE: DO NOT CHECK AGAINST PARENTS OF CATEGORY NOTIFICATION

**********************************************************************

    DATA lt_root_data   TYPE        /iam/t_act_root.

    DATA lr_root_data   TYPE REF TO /iam/s_act_root.

    DATA lt_key         TYPE        /bobf/t_frw_key.

    DATA lr_key         TYPE REF TO /bobf/s_frw_key.

    DATA lt_par_act     TYPE        /iam/t_act_root.

    DATA lr_par_act     TYPE REF TO /iam/s_act_root.

    DATA lt_par_issue   TYPE        /iam/t_i_root.

    DATA lr_par_issue   TYPE REF TO /iam/s_i_root.

    DATA lr_failed_key  TYPE REF TO /bobf/s_frw_key.

    DATA lo_msg         TYPE REF TO /iam/cm_i_bobf_validation.

    DATA lv_attr1       TYPE        scx_attrname.

    DATA lv_attr2       TYPE        scx_attrname.

    DATA lv_activity_id TYPE /iam/activity_id.

    DATA lv_issue_id    TYPE        /iam/issue_id.

    "Read data for activity ROOT node

io_read->retrieve(

EXPORTING

iv_node                 = is_ctx-node_key

it_key                  = it_key

iv_fill_data            = abap_true

IMPORTING

et_data                 = lt_root_data

      ).

    LOOP AT lt_root_data REFERENCE INTO lr_root_data.

"check status of parent activity and parent change request

"activity

CLEAR: lt_key, lt_par_act.

APPEND INITIAL LINE TO lt_key REFERENCE INTO lr_key.

lr_key->key = lr_root_data->par_act_uuid.

io_read->retrieve(

EXPORTING

iv_node                 = is_ctx-node_key

it_key                  = lt_key

iv_fill_data            = abap_true

IMPORTING

et_data                 = lt_par_act

       ).

LOOP AT lt_par_act REFERENCE INTO lr_par_act.

IF ( lr_par_act->lcycle_cd = /iam/if_act_activity_status_c=>sc_root-lifecycle-v_approved

OR lr_par_act->lcycle_cd = /iam/if_act_activity_status_c=>sc_root-lifecycle-v_not_relevant

OR lr_par_act->lcycle_cd = /iam/if_act_activity_status_c=>sc_root-lifecycle-v_completed )

AND lr_par_act->act_category ne /iam/if_appl_c=>sc_notification.

"parent activity is in a final state. re-open is not possible. throw error message

APPEND INITIAL LINE TO et_failed_key REFERENCE INTO lr_failed_key.

lr_failed_key->key = lr_root_data->key.

CLEAR: lv_attr1, lv_attr2, lv_activity_id.

WRITE lr_par_act->activity_id TO lv_activity_id.

lv_attr1 = lv_activity_id.

lv_attr2 = lr_par_act->status_descr.

"create the error message to be added in the message area

CREATE OBJECT lo_msg

EXPORTING

lifetime       = /bobf/cm_frw=>co_lifetime_transition

symptom        = /bobf/if_frw_message_symptoms=>co_cross_bo_mismatch

textid         = /iam/cm_act_bobf_validation=>activity_reopen_par_act_final

severity       = /bobf/cm_frw=>co_severity_error

mv_application = lr_par_act->application

mv_ui_relevant = abap_true

mv_attr1       = lv_attr1

mv_attr2       = lv_attr2.

IF eo_message IS NOT BOUND.

eo_message = /bobf/cl_frw_factory=>get_message( ).

ENDIF.

eo_message->add_cm( lo_msg ).

ENDIF.

ENDLOOP.

"change request

CLEAR: lt_key, lt_par_issue.

APPEND INITIAL LINE TO lt_key REFERENCE INTO lr_key.

lr_key->key = lr_root_data->par_issue_uuid.

"get the issue service manager

      IF CORE_OBJECT->mo_service_manager_issue IS NOT BOUND.

        CORE_OBJECT->mo_service_manager_issue  = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( /iam/if_i_issue_c=>sc_bo_key ).

ENDIF.

"get all issue root information

      CORE_OBJECT->mo_service_manager_issue->retrieve(

EXPORTING

iv_node_key             = /iam/if_i_issue_c=>sc_node-root

it_key                  = lt_key

iv_fill_data            = abap_true

IMPORTING

et_data                 = lt_par_issue

).

LOOP AT lt_par_issue REFERENCE INTO lr_par_issue.

IF lr_par_issue->lcycle_cd = /iam/if_i_issue_status_c=>sc_root-lifecycle-v_closed

OR lr_par_issue->lcycle_cd = /iam/if_i_issue_status_c=>sc_root-lifecycle-v_not_applicable

OR lr_par_issue->deferral_cd = /iam/if_i_issue_status_c=>sc_root-deferral-v_rejected

OR lr_par_issue->deferral_cd = /iam/if_i_issue_status_c=>sc_root-deferral-v_on_hold.

"parent activity is in a final state. re-open is not possible. throw error message

APPEND INITIAL LINE TO et_failed_key REFERENCE INTO lr_failed_key.

lr_failed_key->key = lr_root_data->key.

CLEAR: lv_attr1, lv_attr2, lv_issue_id.

WRITE lr_par_issue->issue_id TO lv_issue_id.

lv_attr1 = lv_issue_id.

lv_attr2 = lr_par_issue->status_descr.

"create the error message to be added in the message area

CREATE OBJECT lo_msg

EXPORTING

lifetime       = /bobf/cm_frw=>co_lifetime_transition

symptom        = /bobf/if_frw_message_symptoms=>co_cross_bo_mismatch

textid         = /iam/cm_act_bobf_validation=>activity_reopen_issue_final

severity       = /bobf/cm_frw=>co_severity_error

mv_application = lr_par_issue->application

mv_ui_relevant = abap_true

mv_attr1       = lv_attr1

mv_attr2       = lv_attr2.

IF eo_message IS NOT BOUND.

eo_message = /bobf/cl_frw_factory=>get_message( ).

ENDIF.

eo_message->add_cm( lo_msg ).

ENDIF.

ENDLOOP. " AT lt_par_issue REFERENCE INTO lr_par_issue.

ENDLOOP. " AT lt_root_data REFERENCE INTO lr_root_data.

ENDMETHOD.

  1. ENDCLASS.

4.5 Workflow: suppress mail notification

The default mail notification might be confusing, since there no action required. You could customize a different mail message for the phase completion, or you can simply suppress the email for these activity types, e.g. via a trigger condition: 

4.6 Application: Resulting behavior

Once all tasks are done, the phase will be show the green completion icon automatically, i.e. no further manual update is required.

:

The status log of the evaluation phase activity will show the automated completion via the workflow user: 

Former Member

No comments