cancel
Showing results for 
Search instead for 
Did you mean: 

Can I modify View elements in init method?

Former Member
0 Kudos

Hi All.

My requirement is that initially the view is empty.

It will embed components (with their views) dynamically at runtime reading from a custom table.

So I have to insert VIEWCONTAINERUI element in the wddoinit() method, and then place the components in theose view container elements.

I know how to insert view container ui elements dynamically in the wddomodify() method.

But, how, and, can I do it in the wddoinit method?

How to get a reference to the IF_WD_VIEW ?

Your advice is highly appreciated.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

mohammed_anzys
Contributor
0 Kudos

Hi,

You cant edit view elements in DOINIT.YOu have to do it in WDDOMODIFY ,as in the INIT method, the view will not be generated.But at the time of WDDOMODIFY , the view will be already created and will be available as a parameter.Moreover there is a parameter FIRST_TIME available in the WDDOMODIFY.Using the this , you can run your specific code only once ( during the first time, not every time the WDDOMODIFY is called ) .

If FIRST_TIME = abap_true.

<<<Your code.

ENDIF.

Thanks

Anzy

Message was edited by:

Mohammed Anzy S

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Aishi,

you could try to get the reference of the view using a method like this:

Importing: i_window (name of the window)

i_view ( name of the view )

Exporting: eo_view ( view-reference )

METHOD get_view_object .
  DATA:
    lo_window_manager TYPE REF TO if_wd_window_manager,
    lo_api_component  TYPE REF TO if_wd_component,
    lo_window         TYPE REF TO if_wd_window
DATA:
    ls_view_manager   TYPE wdr_viewman_line,
    ls_view_line      TYPE wdr_viewmap_line,
    lo_tmp            TYPE REF TO cl_wdr_client_application.

  lo_api_component  = wd_this->wd_get_api( ).
  lo_window_manager = lo_api_component->get_window_manager( ).


  lo_tmp ?= lo_window_manager.

  READ TABLE lo_tmp->view_managers_for_window
       INTO ls_view_manager
       WITH TABLE KEY name = i_window.

  CHECK sy-subrc = 0.

  READ TABLE ls_view_manager-view_manager->views_for_id
       INTO ls_view_line
       WITH TABLE KEY name = i_view.

  CHECK sy-subrc = 0.

  eo_view = ls_view_line-view.

ENDMETHOD.

this one is working fine for me.

kind regards,

Vincent

Former Member
0 Kudos

View elements can be changed only in the wddomodifyview method. the parameter 'view' in the method referes to if_wd_view. To get any element, you can use the method view->get_element( ) and set its properites.

But since the modify view method will be called for every action on your view, you can probably set some flags in the other methods(event handlers) and modify your view only based on the flags.

Regards

Nithya