on 11-06-2013 6:53 PM
My scenario is :
I have two input fields and one button that should be comes under the GROUP while displaying in the screen?
How can i acheive that ? can any one please tell me quickly?
please be sure that is dynamically created
eg: using cl_wd_group->new_group
i think everybody understood correctly
Hello,
There is some solution for this.
1.Create a new group dynamically and the input filed and button also dynamically .
2. If you have fix UI element then why you want to make them dynamically you can set the visibility also.
3. If you have input field and button statically and group dynamically then add your group as child element of your TC, and remove the reference of input field and button from TC and add that child to group.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is a sample code that work :
" For dynamic Programing we need to write code in modify view..
IF first_time = abap_true.
DATA lr_container TYPE REF TO cl_wd_uielement_container.
DATA: lr_matrix TYPE REF TO cl_wd_matrix_head_data,
lr_matrix_lay TYPE REF TO cl_wd_matrix_layout.
DATA: lr_group TYPE REF TO cl_wd_group,
lr_label TYPE REF TO cl_wd_label,
lr_input_field TYPE REF TO cl_wd_input_field,
lr_button TYPE REF TO cl_wd_button.
*** getting reference of first ROOTUIELEMENTCONTAINER
lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
cl_wd_matrix_layout=>new_matrix_layout( lr_container ) .
*** Creating the group
lr_group = cl_wd_group=>new_group( id = 'DYNAMIC_GROUP' enabled = abap_true ).
*** adding to root element but you can add it elsewhere if you want
lr_container->add_child( lr_group ).
*** setting matrix layout head data for the group
cl_wd_matrix_head_data=>new_matrix_head_data( lr_group ).
*** setting matrix layout for the group also
cl_wd_matrix_layout=>new_matrix_layout( lr_group ).
*** Creating the inputfield assuming you have a context element to
*** bind for the value in the view 'MAINVIEW', node 'VALUES' and
*** element INPUTFIELD1. But you may want to generate it dynamicaly also...
lr_input_field = cl_wd_input_field=>new_input_field(
id = 'DYNAMIC_IF1'
bind_value = 'VALUES.INPUTFIELD1').
lr_label = cl_wd_label=>new_label(
text = 'Label for dynamic input field 1'
id = 'DYNAMIC_LABEL1'
label_for = 'DYNAMIC_IF1' ).
lr_group->add_child( lr_label ).
cl_wd_matrix_head_data=>new_matrix_head_data( lr_label ).
lr_group->add_child( lr_input_field ).
cl_wd_matrix_head_data=>new_matrix_data( lr_input_field ).
*** repeat for the other input field.
lr_input_field = cl_wd_input_field=>new_input_field(
id = 'DYNAMIC_IF2'
bind_value = 'VALUES.INPUTFIELD2').
lr_label = cl_wd_label=>new_label(
text = 'Label for dynamic input field 2'
id = 'DYNAMIC_LABEL2'
label_for = 'DYNAMIC_IF2' ).
lr_group->add_child( lr_label ).
cl_wd_matrix_head_data=>new_matrix_head_data( lr_label ).
lr_group->add_child( lr_input_field ).
cl_wd_matrix_head_data=>new_matrix_data( lr_input_field ).
*** create the button. Here you will have either to bind a generic action that will
*** determine which button has been clicked or generat a dynamic action too.
lr_button = cl_wd_button=>new_button(
id = 'DYNAMIC_BUTTON1'
* on_action =
text = 'Click me' ).
lr_group->add_child( lr_button ).
cl_wd_matrix_head_data=>new_matrix_head_data( lr_button ).
ENDIF.
And the result :
Hi Chandra,
Giraud's post isn't against SCN's rules actually.
Everybody's style is different and while I agree it is of course beneficial to "learn by doing", an exact answer is probably what we're all hoping for when we post a question .
Cheers,
Amy
Amy, check out this thread http://scn.sap.com/thread/3437565
Hi,
To understand the requirement correctly :
Do you need to create the GROUP , input fields & button dynamically and arrange them ?
or
Dynamically create only Group and arrange the existing input fields & buttons inside the group?
Regards,
Rama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sri,
Then it won't be much difficult for you to develop this. Just create a group under the root TC.and give matrix layout and then create other UI element under that group.\
you can use this document as reference for creation of dynamic UI.. ..
for creation of new group.
data: lri_Uwe_1 type ref to CL_WD_GROUP.
lri_Uwe_1 = cl_wd_group=>new_group(.....).
for creation of input field..
data: lri_Uwe_2 type ref to CL_WD_INPUT_FIELD.
lri_Uwe_2 = cl_wd_input_field=>new_input_field(.........).
for button,,
data: lri_Uwe_4 type ref to CL_WD_BUTTON.
lri_Uwe_4 = cl_wd_button=>new_button(-------).
Hi Agarwal,
I had created this but i am getting the dump like ''NULL OBJECT REFERENCE" if am creating a group . otherwise without group i will not get the dump
please check my code below
code:
* Instance for dynamic UI creation.
DATA: lr_lbl_vbeln TYPE REF TO cl_wd_label,
lr_inp_vbeln TYPE REF TO cl_wd_input_field,
lo_nd_zvbap TYPE REF TO if_wd_context_node,
lr_text_view TYPE REF TO cl_wd_text_view,
lr_button TYPE REF TO cl_wd_button,
lr_container TYPE REF TO cl_wd_uielement_container,
lr_mat_h_data TYPE REF TO cl_wd_matrix_head_data,
lr_mat_data TYPE REF TO cl_wd_matrix_data,
lr_grp_cont TYPE REF TO cl_wd_group.
********************************************************************
*Creating the node
lo_nd_zvbap = wd_context->get_child_node( name = wd_this->wdctx_zvbap ).
********************************************************************
IF first_time = abap_true.
lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
********************************************************************
*Creating the Group Dynamically.
CALL METHOD cl_wd_group=>new_group
EXPORTING
id = 'GRP_CONT'
design = `01`
enabled = abap_true
has_content_padding = abap_true
scrolling_mode = `02`
visible = `02`
RECEIVING
control = lr_grp_cont.
* layout settings.
lr_mat_h_data = cl_wd_matrix_head_data=>new_matrix_head_data( lr_grp_cont ).
lr_grp_cont->set_layout_data( lr_mat_h_data ).
********************************************************************
*Creating the label Field Dynamically.
CALL METHOD cl_wd_label=>new_label
EXPORTING
design = cl_wd_label=>e_design-emphasized
enabled = 'X'
id = 'LB_VBELN'
label_for = 'VBELN'
text = 'Sales Order Number'
RECEIVING
control = lr_lbl_vbeln.
* Layout Allingment.
lr_mat_h_data = cl_wd_matrix_head_data=>new_matrix_head_data( lr_lbl_vbeln ).
lr_lbl_vbeln->set_layout_data( lr_mat_h_data ).
********************************************************************
*Creating the input Field Dynamically.
CALL METHOD cl_wd_input_field=>new_input_field
EXPORTING
bind_value = 'I_VEBLN.VBELN'
id = 'VBELN'
RECEIVING
control = lr_inp_vbeln.
* Layout Allingment.
lr_mat_data = cl_wd_matrix_data=>new_matrix_data( lr_inp_vbeln ).
lr_inp_vbeln->set_layout_data( lr_mat_data ).
********************************************************************
*Creating the Button Dynamically.
CALL METHOD cl_wd_button=>new_button
EXPORTING
enabled = 'X'
id = 'B1'
on_action = 'GET_DATA'
text = 'GET DATA'
RECEIVING
control = lr_button.
* Layout Allingment.
lr_mat_h_data = cl_wd_matrix_head_data=>new_matrix_head_data( lr_button ).
lr_button->set_layout_data( lr_mat_h_data ).
********************************************************************
*Adding Child Nodes
CALL METHOD lr_container->add_child
EXPORTING
index = 2
the_child = lr_grp_cont.
CALL METHOD lr_container->add_child
EXPORTING
index = 3
the_child = lr_lbl_vbeln.
CALL METHOD lr_container->add_child
EXPORTING
index = 4
the_child = lr_inp_vbeln.
CALL METHOD lr_container->add_child
EXPORTING
index = 5
the_child = lr_button.
maybe this could work without two things :
1- not using the set_layout_data( lr_mat_h_data ) method
2- not giving index parameter to the method add_child of the container. Just call add_child in order.
also you could use :
cl_wd_matrix_layout=>new_matrix_layout( lr_container ) .
after :
lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
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.