cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to refresh task hierarchy after creating some tasks programmatically?

jj1
Associate
Associate
0 Likes
522

Hi,

How can I get the left task hierarchy (or tree) get refreshed with new tasks which are created by myself programmatically in cPro 4.5?

I created some tasks under the exising task but they are not shown in the left task hierarchy automatically, only shown after I refresh the page manually or by re-entering the project again.

Thanks in advance for your help. Any suggestion would be helpful.

Best regards,

Beiyang

View Entire Topic
jj1
Associate
Associate
0 Likes

Code below notifies the dpr_tree webdynpro component of the creation of a task.

The dpr_tree component will receive the changes and upate itself in its on_update method.

(Please be aware that the parents of the newly created task to the root node should already be loaded in the tree)

The important method is lr_api_chg_hndlr->NOTIFY_CREATE(


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  data lv_objtype type cgpl_object_type.
  data lr_chg_mgr type ref to cl_dpr_ui_change_manager.
  DATA: lv_root_node    type string,
        lv_bo_obj_type  TYPE string,
        lv_bo_node_name TYPE string,
        lv_bo_name      type string.
  DATA: lv_api_struc TYPE string.

  data lr_api_chg_hndlr type ref to IF_DPR_CHANGE_HANDLER.
  data: lv_obj_type type cgpl_object_type.
  data lr_cx_root type ref to cx_root.


  TRY .

    IF ir_common is INITIAL or iv_guid is INITIAL.
      return.
    ENDIF.

    lr_chg_mgr = cl_dpr_ui_change_manager=>get_instance( ).
    lv_obj_type = ir_common->get_object_type( ).
    lr_api_chg_hndlr = CL_DPR_API_CHANGE_HANDLER=>get_instance( ).

    CALL METHOD cl_dpr_ui_services=>get_api_data_for_object_type
          EXPORTING
            iv_object_type    = lv_obj_type
          IMPORTING
            ev_root_node      = lv_root_node
            ev_api_structure  = lv_api_struc
            ev_bo_object_type = lv_bo_obj_type
            ev_bo_name        = lv_bo_name.
    CONCATENATE
      lv_bo_obj_type
      cl_dpr_api_co=>sc_separator
      cl_dpr_api_co=>sc_bo_node_name_root
      INTO lv_bo_node_name.

***********************************************
* notify the change of new task
***********************************************
    data lv_tmp_guid type string.
    lv_tmp_guid = iv_guid.
    lr_api_chg_hndlr->NOTIFY_CREATE(
      Exporting IN_BO_NODE_NAME = lv_bo_node_name
        IN_BO_NODE_KEY = lv_tmp_guid
        ).
    lr_chg_mgr->merge_change_notifications( ).
    cl_dpr_ui_event_source=>start_report_change_events( ).

  CATCH cx_root into lr_cx_root.
* do the error handling here
  ENDTRY.

Edited by: Beiyang Xu on Jun 8, 2009 9:03 AM