i am trying to learn dynamic programming , in due course i tried creatiing a button button and my code is like this (in modifyview method )please , tell me how to resolve the following error.........
DATA container TYPE REF TO cl_wd_uielement_container.
DATA button TYPE REF TO cl_wd_button .
IF first_time = abap_true .
container ?= view->get_element('ROOTELEMENTCONTAINER').
cl_wd_button=>new_button(
EXPORTING
id = 'first'
text = 'First Dynamic Button'
RECEIVING
control = button ).
DATA grid_data TYPE REF TO cl_wd_grid_data.
cl_wd_grid_data=>new_grid_data(
EXPORTING
ELEMENT = button
col_span = '2'
RECEIVING
control = grid_data
).
button->set_layout_data( lr_grid_data ).
container->add_child(
EXPORTING
the_child = button
index = 1 ).
ENDIF.
this gives me following runtime error : access via null object reference is not possible .
One more thing i would like to ask , hoe to add more than one ui element as cl_wd_grid_data=>new_grid_data(
EXPORTING
ELEMENT = button
col_span = '2'
RECEIVING
control = grid_data
).
this method takes only one object.
thank you..