cancel
Showing results for 
Search instead for 
Did you mean: 

Webdynpro Dynamic layout manipulation: error attaching elements to Group

Former Member
0 Kudos

Hi Experts,

I am trying to create dynamic layout during run time. Itu2019s working partially, but as soon as I add new u201CGroup elementu201D or new u201CTransparent elementu201D I am getting a null error. If I just use buttons, input field or text dynamically layout create it works fine. I want to group this fields in a groups or transparent container so that I can manipulate layout place containers where I need. As soon as I add other element (inputfield/button/text) to transparent element it errors. I have attached code below for more detail. Does anyone have similar issue? Lot of demo and example code show how to create elements (inputfield/button/text) none show how attach those element back to u201DGroupu201D or u201CTransparentu201D element.

I am creating dynamic elements in u201CViewu201D method u201CWDDOMODIFYVIEWu201D. Any idea or clue much appreciated. Thanks in advance.

Kind Regards,

Trim

method WDDOMODIFYVIEW .

DATA lr_container TYPE REF TO cl_wd_uielement_container.

DATA lr_trans_cont TYPE REF TO CL_WD_TRANSPARENT_CONTAINER.

DATA lr_input TYPE REF TO cl_wd_input_field.

DATA lr_table TYPE REF TO cl_wd_table.

DATA lo_nd_sflight TYPE REF TO if_wd_context_node.

DATA lr_button TYPE REF TO cl_wd_button.

DATA lr_o_group TYPE REF TO cl_wd_group.

data: lr_text TYPE REF TO CL_WD_TEXT_VIEW.

constants : gc_trs_cont type string value 'Trscont',

gc_text1 type string value 'ePDA goals and activity of the team',

gc_text2 type string value 'Complete all box and submit to manager'.

DATA lo_el_context TYPE ref to if_wd_context_element.

  • navigate from <CONTEXT> to <SFLIGHT> via lead selection

lo_nd_sflight = wd_context->get_child_node( name = wd_this->wdctx_sflight ).

IF first_time = abap_true.

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

DATA lr_grid_data TYPE REF TO cl_wd_grid_data.

DATA lr_flow_data TYPE REF TO cl_wd_flow_data.

DATA lr_matrix TYPE REF TO cl_wd_matrix_head_data.

DATA lr_matrix_l TYPE REF TO cl_wd_matrix_layout.

DATA lr_matrix2 TYPE REF TO cl_wd_matrix_data.

        • CALL METHOD CL_WD_TRANSPARENT_CONTAINER=>NEW_TRANSPARENT_CONTAINER

        • EXPORTING

        • ID = '/0CUST/123'

        • VIEW = view

        • WIDTH = '100%'

        • RECEIVING

        • CONTROL = lr_trans_cont.

****

        • lr_matrix = cl_wd_matrix_head_data=>new_matrix_head_data( lr_trans_cont ).

        • lr_container->set_layout_data( lr_matrix ).

data: lr_o_caption type ref to cl_wd_caption.

CALL METHOD CL_WD_GROUP=>NEW_GROUP

EXPORTING

ID = 'GRP1'

design = '03'

RECEIVING

CONTROL = lr_o_group.

  • lr_o_caption = cl_wd_caption=>new_caption( text = 'Group1' ).

  • lr_o_group->set_header( the_header = lr_o_caption ).

  • cl_wd_flow_data=>new_flow_data( element = lr_o_group ).

  • cl_wd_flow_layout=>new_flow_layout( container = lr_o_group ).

lr_matrix = cl_wd_matrix_head_data=>new_matrix_head_data( lr_o_group ).

lr_o_group->set_layout_data( lr_matrix ).

CALL METHOD lr_container->add_child

EXPORTING

index = 1

the_child = lr_o_group.

CALL METHOD cl_wd_button=>new_button

EXPORTING

enabled = 'X'

id = 'B1'

on_action = 'GET_FLIGHT'

text = 'Get Flight Data'

RECEIVING

control = lr_button.

lr_matrix2 = cl_wd_matrix_data=>new_matrix_data( lr_button ).

lr_button->set_layout_data( lr_matrix2 ).

CALL METHOD lr_o_group->add_child

EXPORTING

  • index = 1

the_child = lr_button.

CALL METHOD cl_wd_input_field=>new_input_field

EXPORTING

bind_value = 'SFLIGHT.CARRID'

id = 'INPUT1'

RECEIVING

control = lr_input.

lr_matrix2 = cl_wd_matrix_data=>new_matrix_data( lr_input ).

  • lr_input->set_layout_data( lr_matrix2 ).

CALL METHOD lr_o_group->add_child

EXPORTING

  • index = 2

the_child = lr_input.

endmethod.

Edited by: Trim Chakrapani on Nov 15, 2011 5:01 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

I suggest you create a transparent container at design time and then use the below code in wddomodify to get a reference to the transparent container.

DATA: lv_container TYPE string,

lo_container TYPE REF TO cl_wd_transparent_container.

lv_container = 'TransparentContainer'.

lo_container ?= view->get_element( lv_container ).

lo_container->add_child( lo_button ).

Hope this helps.

Former Member
0 Kudos

Hi Lorraine,

Thanks for your reply, I can't do that during design time because i don't know how many i need. Any way thanks for reply.

Regards,

Trim

Former Member
0 Kudos

i think the problem is that your "ROOTCONTAINERELEMENT" by default flow layout.

If you change that to Matrix Layout then the rest will work fine.

Answers (0)