Skip to Content
0
Oct 20, 2011 at 10:19 AM

registering a object at runtime

37 Views

Hi Experts,

In one of the standard code the I am trying to add an enhancement to add a note during the runtime. My enhancement is after the below standard code.

I can observe that the object is being deregistered during runtime which causes the code I am trying to implement not to work.

* set Data to pdo-object
    "prepare call
    lo_pdo_sc ?= mo_pdo.
 
 
    "call
    TRY.
        lo_pdo_sc->add_item( EXPORTING is_item   = ls_pdo_item
                                       iv_uname  = sy-uname
                                       iv_account_for_ess = iv_ess
                             IMPORTING es_return = ls_pdo_item_control
                             CHANGING  co_message_handler = mo_pdo_message_consumer ).
 
* Add internal note as longtext
        wd_main_node = mon_cll_set_facade->get_main_node( ).
        wd_child_node = wd_main_node->get_child_node( name = 'INTERNAL_NOTE' ).
        wd_child_node->get_attribute( EXPORTING name = 'INTERNAL_NOTE' IMPORTING value = lv_internal_note ).
 
        TRY.
            CALL METHOD lo_pdo_sc->/sapsrm/if_pdo_do_longtext~update_longtext
              EXPORTING
                iv_p_guid          = ls_pdo_item_control-guid
                iv_tdid            = 'NOTE'
                iv_tdspras         = sy-langu
                iv_tdformat        = 'X'
                iv_text_preview    = lv_internal_note
*              CHANGING
*                EV_CHANGED         = LV_CHANGED
*    CO_MESSAGE_HANDLER =
                .
 
          CATCH /sapsrm/cx_pdo_abort INTO lx_pdo_abort.
            mo_cll_message_handler->set_abort( io_pdo_abort_exception = lx_pdo_abort ).
        ENDTRY.
 
* update
        mo_pdo->submit_update( CHANGING co_message_handler = mo_pdo_message_consumer ).
 
* because view will be invalidated: clear the mapper reference from the bo_mapper
>>>>>>        mo_parent_bo_mapper->deregister_mapper( io_mapper = me ).
 
* refresh whole application because e.g. Total value of sc has maybe changed.
* updates were performed a step before
        mo_parent_bo_mapper->fire_event_refresh( iv_perform_updates = abap_false ).
 
* close window
        lo_window_controller = mo_wd_view_controller->get_embedding_window_ctlr( ).
        lo_window = lo_window_controller->get_window( ).
        lo_window->close( ).
        ev_close_window = abap_true.

The code I have implemented in the enhancement is given below, the buffer is updated but I guess due to the object not registered to BO mapper the updates are not visible in the webdynpro screen.

* get context-data
  io_mon_cll_set_facade->get_static_attributes( IMPORTING es_static_attributes = ls_cll_item ).

* Get longtext note
  wd_main_node = io_mon_cll_set_facade->get_main_node( ).
  wd_child_node = wd_main_node->get_child_node( name = 'NOTE' ).
  wd_child_node->get_attribute( EXPORTING name = 'NOTE' IMPORTING value = lv_note ).

  TRY.
      CALL METHOD io_pdo_sc->/sapsrm/if_pdo_do_longtext~update_longtext
        EXPORTING
          iv_p_guid          = is_pdo_item_control-guid
          iv_tdid            = 'HTXT'
          iv_tdspras         = sy-langu
          iv_tdformat        = 'X'
          iv_text_preview    = lv_note
*              CHANGING
*                EV_CHANGED         = LV_CHANGED
*    CO_MESSAGE_HANDLER =
          .
    CATCH /sapsrm/cx_pdo_abort INTO lx_pdo_abort.
      co_mo_cll_message_handler->set_abort( io_pdo_abort_exception = lx_pdo_abort ).
  ENDTRY.
* update
  io_pdo->submit_update( CHANGING co_message_handler = co_mo_pdo_message_consumer ).
ENDMETHOD.

Can someone tell me what is the correct way to get the updated data captured during runtime?