cancel
Showing results for 
Search instead for 
Did you mean: 

How to refresh task hierarchy after creating some tasks programmatically?

jj1
Associate
Associate
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Beiyang,

If you are using xRPM portal and cProjects within that, please consider the option of refreshing the cache memory.

If you are connected to cProjects directly without xRPM, you can always close that project. Go to another tab and then open that project again. I believe it works.

Please let me know if it solves your query.

Regards,

Nishit Jani

jj1
Associate
Associate
0 Kudos

Hi Nishit,

First thank you for the suggestion here. Is there any sample code for that?

I am a newbie for cPro, don't know how I could do to get the cache refreshed programmatically or close/open the project by code.

I am trying to find some sample code to refresh the task hierarchy programmatically, currently I am checking on CL_DPR_PROJECT and CL_DPR_TASK but don't know whether this is the correct direction.

Thanks and regards,

Beiyang

Former Member
0 Kudos

Hi Beiyang,

If you are using cProjects in xRPM Portal, then go to Portfolio Management > Administration > Cache Administration > Invalidate selected Cache..

By doing so, it refreshes the cache and the real time data is getting displayed. But this is manual mode.

Regards,

Nishit Jani

Answers (1)

Answers (1)

jj1
Associate
Associate
0 Kudos

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