cancel
Showing results for 
Search instead for 
Did you mean: 

creation of elements in WDDOINIT

Former Member
0 Kudos

Hi Experts,

Is there any option to create UI elements in the WDDOINIT method, if possible kindly suggest me how to achieve that

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vikranth,

I dont think there is any way to create UI element in WDDOINIT as for creating UI element u need the reference of View. But same functionally you can archive by writing the code in WDDoModifyView method.

Check the value to First_Time parameter of WDDoModifyView method.

if First_Time = 'X'.

write ur code for createing UI element

endif.

And SAP also recommend to do this kind of think in WDDoModifyView method.

Regards,

Vikram

Answers (2)

Answers (2)

Former Member
0 Kudos

You cann't create UI elements from WDINIT method ,since view instance is not available in DOINIT.

check this code

if first_time = 'X'.

method wddomodifyview .

data:lr_container type ref to cl_wd_uielement_container,

lr_table type ref to cl_wd_table,

lr_layout type ref to cl_wd_flow_data,

node_flights type ref to if_wd_context_node,

it_flights type sflight_tab1,

lr_node type ref to if_wd_context_node_info.

node_flights = wd_context->get_child_node( 'SFLIGHT' ).

select * from sflight into table it_flights up to 100 rows.

node_flights->bind_table(

new_items = it_flights

  • SET_INITIAL_ELEMENTS = ABAP_TRUE

  • INDEX = INDEX

).

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

lr_table = cl_wd_dynamic_tool=>create_table_from_node(

ui_parent = lr_container

table_id = 'TABLE1'

node = node_flights

  • ON_LEAD_SELECT = ON_LEAD_SELECT

).

lr_layout = cl_wd_flow_data=>new_flow_data(

  • CELL_DESIGN = E_CELL_DESIGN-PADLESS

element = lr_table

  • ID = ID

  • V_GUTTER = E_V_GUTTER-NONE

).

endif.

also check standard exapmle DODYNAMIC

thanks

Suman

Former Member
0 Kudos

Hi Vikranth,

wddoinit is called when the view is loaded in the memory for the first time, that is when the view controller is initialized, not when the view is displayed.

The view is first loaded in memory and then it is displayed on the screen. Accordingly, the wddoinit method is called first and then the wddomodifyview method.

I believe your requirement is to create ui elements dynamically when the view is displayed for the first time. This can be done in wddomodifyview by checking the parameter FIRST_TIME to be true. This is a standard parameter available in the wddomodifyview method.

The ideal way to do what you want will be to do it in wddomodifyview. The problem with wddoinit is that the reference of if_wd_view is not available in this method (while it is available in wddomodifyview). This reference is required to add new elements to the view.

The reference of if_wd_view is required to get a container reference on the view to which the ui elements can be added. Without this, it is not possible to add any elements as it will not be known that which container is going to hold these elements.

hope that clarifies the point...

Former Member
0 Kudos

thanks for the valuable suggestions