cancel
Showing results for 
Search instead for 
Did you mean: 

Create Link to Action dynamically

Former Member
0 Kudos

Hi,

I want to create "Link to Action" element at runtime inside a transparent container.

can anybody help me out in this.

Regards,

Kanakaraj V A

Accepted Solutions (0)

Answers (3)

Answers (3)

arjun_thakur
Active Contributor
0 Kudos

Hi Kanakaraj,

You should also go through these blogs:

[blog1|/people/thomas.szcs/blog/2005/12/28/dynamic-programming-in-web-dynpro-abap--introduction-and-part-i-understanding-ui-elements],

[blog2|/people/thomas.szcs/blog/2006/01/03/dynamic-programming-in-web-dynpro-abap--part-ii-handling-viewelements],

[blog3|/people/thomas.szcs/blog/2006/02/22/dynamic-programming-in-web-dynpro-abap--part-iii-aggregations-and-ddic-binding-of-viewelements].

These will help you to understand the basics of dynamic programming.

Regards

Arjun

Former Member
0 Kudos

Kankaraj,

check this

data lr_link_to_action type ref to cl_wd_link_to_action.

  • data:

  • lr_view type ref to cl_wdr_view,

  • lr_tray type ref to cl_wd_tray,

  • lr_grid_data type ref to cl_wd_grid_data.

    • we need to cast the view to a more specialized class for our calls

  • lr_view ?= view.

    • create a linktoaction for the current view element inside of the current tray

  • lr_link_to_action = cl_wd_link_to_action=>new_link_to_action(

  • id = 'ID'

  • on_action = 'DISPLAY_DETAIL'

  • text = 'text'

  • view = lr_view ).

    • create the grid layout data for the link to action

  • lr_grid_data = cl_wd_grid_data=>new_grid_data( lr_link_to_action ).

*

    • assign the layout data to the link to action

  • lr_link_to_action->set_layout_data( lr_grid_data ).

*

    • add the link to action to the current tray

  • lr_tray->add_child( lr_link_to_action ).

create an action with name DISPLAY_DETAIL

Thanks

Bala Duvvuri

Former Member
0 Kudos

Hi Bala,

Thanks a lot for the code.

But i have a doubt, how do i assign it to a particular Transperant container?

Thanks and Regards,

Kanakaraj V A

arjun_thakur
Active Contributor
0 Kudos

Hi Kanakaraj,

Refer this code

DATA: lr_container TYPE REF TO cl_wd_uielement_container,
        lr_lta TYPE REF TO CL_WD_LINK_TO_ACTION,
        lr_view type ref to cl_wdr_view.


  CHECK first_time = abap_true.
  lr_container ?= view->get_element( id = 'ROOTUIELEMENTCONTAINER' ). "give the name of transparent container
  cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).



lr_lta = CL_WD_LINK_TO_ACTION=>NEW_LINK_TO_ACTION(  text = 'lta'
                                                    view = lr_view
                                                    ON_ACTION = 'lta'   ).

 cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_lta ).
  
lr_container->add_child( the_child = lr_lta ).

I hope it helps.

Regards

Arjun

former_member402443
Contributor
0 Kudos

Hi Kankaraj,

You can go thru this code. This will help u in dynamically creating link to action.

method init_view2.

data:

current_library type string value `####`,

lr_tray type ref to cl_wd_tray,

lr_matrix_head_data type ref to cl_wd_matrix_head_data,

lr_matrix_data type ref to cl_wd_matrix_data,

lr_matrix_layout type ref to cl_wd_matrix_layout,

lr_library_group type ref to cl_wd_group,

lr_caption type ref to cl_wd_caption,

caption_id type string,

lr_link_to_action type ref to cl_wd_link_to_action,

max_num_attributes_tmp type i,

attribute type wdr_context_attribute_info,

lt_attributes type wdr_context_attr_info_map,

lr_settings_node_info type ref to cl_wdr_context_node_info,

lr_root_node type ref to cl_wdr_context_node,

ui_elem_def_tmp like line of cl_wdr_all_in_one_uielem=>mt_ui_elem_def_all,

  • lt_ui_prop_def_tmp type wdy_ui_elem_prop_table,

ui_prop_def_tmp like line of cl_wdr_all_in_one_uielem=>mt_ui_prop_def,

lt_ui_event_def_tmp type wdy_md_framework_events,

ui_event_def_tmp like line of lt_ui_event_def_tmp,

lt_ui_evpar_def_tmp type wdy_ui_evpar_def_table,

ui_evpar_def_tmp like line of lt_ui_evpar_def_tmp,

is_ui_element type abap_bool,

lt_event_parameters like cl_wdr_event=>parameters,

event_parameter like line of lt_event_parameters,

tray_id type string,

is_ui_container type abap_bool,

display_name_txt type string,

definition_name_txt type string,

is_expanded type abap_bool,

lr_view_elem_container type ref to cl_wd_uielement_container,

lr_ui_element_tray type ref to cl_wd_tray,

lr_ui_element_root_node type ref to if_wd_context_node.

field-symbols:

<ui_elem_def> like line of cl_wdr_all_in_one_uielem=>mt_ui_elem_def,

<ui_prop_def> like line of cl_wdr_all_in_one_uielem=>mt_ui_prop_def,

<ui_library> like line of cl_wdr_all_in_one_uielem=>mt_ui_library.

  • save the view and the root node

m_view = i_view.

m_context_root_node = i_context_root_node.

  • display the libraries

loop at cl_wdr_all_in_one_uielem=>mt_ui_library assigning <ui_library>.

loop at cl_wdr_all_in_one_uielem=>mt_ui_elem_def assigning <ui_elem_def>

where library_name = <ui_library>-library_name.

  • get a pointer to the library group

lr_library_group ?= i_view->get_element( 'LIBRARIES' ).

  • create a new tray per new library

if current_library <> <ui_elem_def>-library_name.

  • save the name of the new library

current_library = <ui_elem_def>-library_name.

  • create a new tray

concatenate current_library '_LIB' into tray_id.

if current_library = 'STANDARD'.

is_expanded = abap_true.

else.

is_expanded = abap_false.

endif.

lr_tray = cl_wd_tray=>new_tray(

design = CL_WD_TRAY=>E_DESIGN-PLAIN

expanded = is_expanded

id = tray_id

scrolling_mode = CL_WD_IFRAME=>E_SCROLLING_MODE-NONE

view = i_view

width = '100%').

display_name_txt = <ui_library>-display_name.

  • set the caption of the tray

concatenate lr_tray->id '_HEADER' into caption_id.

lr_caption = cl_wd_caption=>new_caption(

id = caption_id

text = display_name_txt

view = i_view ).

lr_tray->set_header( lr_caption ).

  • create the matrix layout data for tray

lr_matrix_head_data = cl_wd_matrix_head_data=>new_matrix_head_data(

element = lr_tray

v_align = CL_WD_GRID_DATA=>E_V_ALIGN-TOP ).

  • assign the layout data to the tray

lr_tray->set_layout_data( lr_matrix_head_data ).

  • create a new matrix layout for the content of the tray

lr_matrix_layout = cl_wd_matrix_layout=>new_matrix_layout(

container = lr_tray

STRETCHED_HORIZONTALLY = abap_false

STRETCHED_VERTICALLY = abap_false ).

  • assign the grid layout to the tray

lr_tray->set_layout( lr_matrix_layout ).

  • add the tray to the library group

lr_library_group->add_child( lr_tray ).

endif.

definition_name_txt = <ui_elem_def>-definition_name.

display_name_txt = <ui_elem_def>-display_name.

    • create a linktoaction for the current view element inside of the current tray*

lr_link_to_action = cl_wd_link_to_action=>new_link_to_action(

id = definition_name_txt

on_action = 'DISPLAY_DETAIL'

text = display_name_txt

view = i_view ).

  • add the parameter mapping

clear lt_event_parameters[].

event_parameter-name = 'CUR_LIBRARY'.

event_parameter-value = <ui_elem_def>-library_name.

insert event_parameter into table lt_event_parameters.

event_parameter-name = 'CUR_UI_ELEMENT'.

event_parameter-value = <ui_elem_def>-definition_name.

insert event_parameter into table lt_event_parameters.

lr_link_to_action->map_on_action( parameters = lt_event_parameters ).

  • create the grid layout data for the link to action

lr_matrix_head_data = cl_wd_matrix_head_data=>new_matrix_head_data( lr_link_to_action ).

  • assign the layout data to the link to action

lr_link_to_action->set_layout_data( lr_matrix_head_data ).

  • add the link to action to the current tray

lr_tray->add_child( lr_link_to_action ).

endloop.

endloop.

    • create an initial view element

  • create object m_cur_view_element.

*

    • create everything within the view to modify the current view element

  • lr_ui_element_tray ?= i_view->get_element( 'VIEWELEMENT' ).

  • lr_view_elem_container ?= i_view->get_element( 'C0_MAIN' ).

  • lr_ui_element_root_node = i_context_root_node->get_child_node( 'UI_ELEMENT' ).

  • m_cur_view_element->create(

  • i_library_name = 'STANDARD'

  • i_definition_name = 'BUTTON'

  • i_cur_level = 0

  • i_parent_container = lr_view_elem_container

  • i_ui_element_tray = lr_ui_element_tray

  • i_root_node = lr_ui_element_root_node ).

  • set the default ui element and library

m_cur_library = 'STANDARD'.

m_cur_ui_element = 'BUTTON'.

  • display it

switch_ui_element2( ).

endmethod.

You can also refer the class - CL_WDR_ALL_IN_ONE_UTIL.

Regards

Manoj Kumar

Edited by: Manoj Kumar on Feb 11, 2009 9:58 AM

Former Member
0 Kudos

Hi Manoj,

Thanks a lot for the code.

But i have a doubt, how do i assign it to a particular Transperant container?

Thanks and Regards,

Kanakaraj V A