on 05-18-2012 7:28 AM
Hi All,
I have a requirement where the whole layout is determined in run time according to a ztable values. I have created a tabstrip, inserted tabs to it, created elements (link to action) that has to be inserted into the different tabs created dynamically. BUt I am getting a dump when i try to do so.. the problem is with inserting the container to the tab. I get Null object reference. PFB the code. This has to be done urgently. Help is highly appreciated. TIA.
method wddomodifyview .
data lr_uielement_container type ref to cl_wd_uielement_container.
data lr_tabstrip type ref to cl_wd_tabstrip.
data lrs_tabstrip type ref to cl_wd_tabstrip.
data lr_matrix_head_data type ref to cl_wd_matrix_head_data.
data lr_tab type ref to cl_wd_tab.
data lv_caption type ref to cl_wd_caption.
data it_zps_reports_port type standard table of zps_reports_port.
data wa_zps_reports_port like line of it_zps_reports_port.
data lv_flag type c.
data lv_text type string.
data lv_link_text type string.
data lr_linktoaction type ref to cl_wd_link_to_action.
data lr_lta_element type ref to cl_wd_uielement.
data lr_scroll_container type ref to cl_wd_scroll_container.
data lr_trans_cont type ref to cl_wd_transparent_container.
data lr_id type string value 'LNK'.
data lr_count type num value 0.
data lr_id_d type string.
data lo_nd_link_to_action type ref to if_wd_context_node.
data lo_el_link_to_action type ref to if_wd_context_element.
data ls_link_to_action type wd_this->element_link_to_action.
data lv_textt type string.
data lo_node type ref to if_wd_context_node.
data lo_nd_info type ref to if_wd_context_node_info.
data:lt_valueset type wdr_context_attr_value_list ,
l_value type wdr_context_attr_value.
data ld_tabstrip type ref to cl_wd_tabstrip.
data: ld_container type ref to cl_wd_uielement_container,
ld_vc type ref to cl_wd_view_container_uielement.
if first_time eq abap_true.
select * from zps_reports_port into corresponding fields of table it_zps_reports_port order by tabx.
sort it_zps_reports_port.
************creation of tabstrip dynamically
lr_uielement_container ?= view->get_element( id = 'ROOTUIELEMENTCONTAINER' ).
call method cl_wd_tabstrip=>new_tabstrip
exporting
id = 'TBS'
receiving
control = lr_tabstrip.
lr_matrix_head_data = cl_wd_matrix_head_data=>new_matrix_head_data(
element = lr_tabstrip
).
lr_tabstrip->set_layout_data( the_layout_data = lr_matrix_head_data ).
lr_uielement_container->add_child(* index = index
the_child = lr_tabstrip
).
lo_node = wd_context->get_child_node( 'LINK_TO_ACTION' ).
lo_nd_info = lo_node->get_node_info( ).
lo_nd_link_to_action = wd_context->get_child_node( name = wd_this->wdctx_link_to_action ).
lo_el_link_to_action = lo_nd_link_to_action->get_element( ).
loop at it_zps_reports_port into wa_zps_reports_port.
*****addition of tab for every new tab.
at new tabx.
lv_flag = abap_true.
endat.
if lv_flag = abap_true.
if wa_zps_reports_port-tabx = 1.
lv_text = 'Billing reports'.
else.
lv_text = 'Monthly closing reports'.
endif.******Addition of new tab
call method cl_wd_caption=>new_caption
exporting
text = lv_text
receiving
control = lv_caption.
call method cl_wd_tab=>new_tab
exporting
enabled = 'X'
has_content_padding = 'X'
receiving
control = lr_tab.
lr_tab->set_header( lv_caption ).
lr_tabstrip->add_tab( the_tab = lr_tab ).
clear lv_flag.
endif.
lr_count = lr_count + 1.
concatenate lr_id lr_count into lr_id_d.
lv_textt = wa_zps_reports_port-trans_code.
call method cl_wd_link_to_action=>new_link_to_action
exporting
id = lr_id_d
on_action = 'ON_ACTION'
text = lv_textt
receiving
control = lr_linktoaction.
lr_matrix_head_data = cl_wd_matrix_head_data=>new_matrix_head_data(
element = lr_linktoaction
).*
lr_linktoaction->set_layout_data( the_layout_data = lr_matrix_head_data ).
lr_linktoaction->set_layout_data( the_layout_data = lr_matrix_head_data ).** lr_uielement_container->add_child(** index = lr_ind* the_child = lr_linktoaction* ).
call method cl_wd_scroll_container=>new_scroll_container
receiving
control = lr_scroll_container
.
lr_scroll_container->add_child( lr_linktoaction ).
lr_tab->set_content( lr_trans_cont ). "im getting dump after the looping is done and the end method is executed
endloop.
endif.endmethod.
Hi,
I am not sure about your problem. But when creating the screen dynamically, even i was getting the same dump while adding container. It got resolved with a simple solution.
While creating every new UI element dynamically, methods have a parameter called 'VIEW'. Here you have to pass the view where you are creating elements.
Say First u create a tabstrinp - add the parameter. Then container withing the tab - add the parameter.
To get the reference of view, from WDDOMODIFYVIEW I saved the reference in a global variable.
Make sure you add the parameter VIEW to every newly created element.
Hope it solves your problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.