on 03-13-2009 10:07 AM
Hi ,
Is there any way we can create 'Text' along with buttons beside the text 'YES' and 'NO' dynamically in a VIEW through 'ABAP WEBDYNPRO'.
Thanks,
kumar
Hi
look at the code, here the button is created dynamically. similarly you can create text view.
http://help.sap.com/saphelp_nw70/helpdata/EN/11/ba74412cba127de10000000a155106/content.htm
you can change the button text using the methods inside CL_WD_BUTTON.
Abhi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
tahnks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Code for dynamic element creation are intended to be written in WDDOMODIFY method. Below code snippet creates two Radio buttons dynamically with texts 'Male' & 'Female'. You can always extend the logic to create as many.
method wddomodifyview .
if first_time eq abap_true.
data: LR_CONTAINER type ref to CL_WD_UIELEMENT_CONTAINER,
LR_RADIOBUTTON1 type ref to CL_WD_RADIOBUTTON,
LR_RADIOBUTTON2 type ref to CL_WD_RADIOBUTTON,
LR_FLOW_DATA type ref to CL_WD_FLOW_DATA.
" bind text property will give TEXT that appears next to Radio Button
CALL METHOD cl_wd_radiobutton=>new_radiobutton
EXPORTING
bind_selected_key = '01'
BIND_TEXT = 'Male'
receiving
control = LR_RADIOBUTTON1.
" bind text property will give TEXT that appears next to Radio Button
CALL METHOD cl_wd_radiobutton=>new_radiobutton
EXPORTING
bind_selected_key = '02'
BIND_TEXT = 'Female'
receiving
control = LR_RADIOBUTTON2.
LR_FLOW_DATA = CL_WD_FLOW_DATA=>NEW_FLOW_DATA( element = LR_RADIOBUTTON1 ).
LR_FLOW_DATA = CL_WD_FLOW_DATA=>NEW_FLOW_DATA( element = LR_RADIOBUTTON2 ).
LR_CONTAINER ?= view->GET_ELEMENT( 'ROOTUIELEMENTCONTAINER' ).
LR_CONTAINER->ADD_CHILD( LR_RADIOBUTTON1 ).
LR_CONTAINER->ADD_CHILD( LR_RADIOBUTTON2 ).
endif.
endmethod.
for more on dynamic programing read blogs from thomas.
[https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2888] [original link is broken] [original link is broken] [original link is broken];
Greetings
Prashant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasanth ,
I tried to with your sample code to create radiobutton group , but its giving me an error message 'Could not find attribute 01'.
My Req is as below :
Is there any way we can create 'Text' along with radio button groups beside the text 'YES' and 'NO' dynamically in a VIEW through 'ABAP WEBDYNPRO'. Can we create a context node with 'TEXT' attribute.
Eg : TEXT RADIOBUTTON1 'yes' RADIOBUTTON2 'no'.
Thanks,
kumar
Hi Kumar,
In sample Code i just set '01' and '02' as sample values..in real scenario the value would be comming from Attribute in the context of your view. syntax would be
bindSelected_key = <V_MyVIEW>.<MYNODE>.<MYKEY>
if you consider below example then you bindSelected_key would read
bindSelected_key = V_MyVIEW.MYNODE.CARRID
[http://help.sap.com/saphelp_nw04s/helpdata/EN/c0/e8884118aa1709e10000000a155106/frameset.htm]
BindSelected_key should have a ValueSet attached. The value set of the attribute bound to the property selectedKey. If the attribute has an ABAP Dictionary type and if fixed domain values are defined for this type, these values are used.
-
creating Valueset----
I Have 1 context node by name INPUT. Below are its properties:
Cardinality: 1..1
Selection: 0..1
Initialization Lead Selection: The box is checked (You get the error message in your component coz this isnt set)
Singleton: The box is checked
Now I have 2 attributes CARRID & CONNID under this node of the types SFLIGHT-CARRID & SFLIGHT-CONNID.
Now within my WDDOINIT method I fill my 2 dropdowns with values like shown below:
data: wd_node type ref to if_wd_context_node,
wd_node_info type ref to if_wd_context_node_info,
** Internal table & workareas to hold possible values for carrid & connid
lt_carrid_values type standard table of wd_this->element_input-carrid,
lt_connid_values type standard table of wd_this->element_input-connid,
wa_carrid type wd_this->element_input-carrid,
wa_connid type wd_this->element_input-connid,
** Internal table & workareas to hold name & value pairs
wa_carrid_valueset type wdr_context_attr_value,
wa_connid_valueset type wdr_context_attr_value,
lt_carrid_valueset type standard table of wdr_context_attr_value,
lt_connid_valueset type standard table of wdr_context_attr_value.
wd_node = wd_context->get_child_node( name = 'INPUT' ).
select distinct carrid from sflight into table lt_carrid_values.
select distinct connid from sflight into table lt_connid_values.
loop at lt_carrid_values into wa_carrid.
wa_carrid_valueset-value = wa_carrid.
wa_carrid_valueset-text = wa_carrid.
append wa_carrid_valueset to lt_carrid_valueset.
clear wa_carrid_valueset.
endloop.
loop at lt_connid_values into wa_connid.
wa_connid_valueset-value = wa_connid.
wa_connid_valueset-text = wa_connid.
append wa_connid_valueset to lt_connid_valueset.
clear wa_connid_valueset.
endloop.
wd_node_info = wd_node->get_node_info( ).
wd_node_info->set_attribute_value_set( exporting name = c
value_set = lt_carrid_valueset ).
wd_node_info->set_attribute_value_set( exporting name = 'CONNID'
value_set = lt_connid_valueset ).
-
Greetings
Prashant
Hi Kumar,
sorry i did'nt initially get that you wanted radionbuttonGROUP. well check the standard webdynpro component WDR_TEST_EVENTS browse to the VIEW
RADIOBTNGRPBYKEY you see that the Radio button Group is bound to context property RadiobtnGrpByKey.selectedKey1.
to create this dynamically check the code with explanation below
method wddomodifyview .
if first_time eq abap_true.
data: LR_CONTAINER type ref to CL_WD_UIELEMENT_CONTAINER,
LR_FLOW_DATA type ref to CL_WD_FLOW_DATA.
data: lr_rbk type ref to cl_wd_radiobutton_group_by_key.
CALL METHOD cl_wd_radiobutton_group_by_key=>new_radiobutton_group_by_key
EXPORTING
bind_selected_key = 'RadiobtnGrpByKey.selectedKey1'
receiving
control = lr_rbk.
*--------------RadiobtnGrpByKey.selectedKey1---------*
*Attribute selectedKey1 that has domain with value range defined as
*00 Application
*01 Component
*02 Template Container
*03 Template
LR_FLOW_DATA = CL_WD_FLOW_DATA=>NEW_FLOW_DATA( element = lr_rbk ).
LR_CONTAINER ?= view->GET_ELEMENT( 'ROOTUIELEMENTCONTAINER' ).
LR_CONTAINER->ADD_CHILD( LR_RADIOBUTTON1 ).
endif.
endmethod.
for detail method of radio group by key check link
[http://help.sap.com/saphelp_nw04s/helpdata/EN/37/a6884121a41c09e10000000a155106/content.htm]
Hi Kumar,
Refer these blogs:
/people/thomas.szcs/blog/2005/12/28/dynamic-programming-in-web-dynpro-abap--introduction-and-part-i-understanding-ui-elements
/people/thomas.szcs/blog/2006/01/03/dynamic-programming-in-web-dynpro-abap--part-ii-handling-viewelements
/people/thomas.szcs/blog/2006/02/22/dynamic-programming-in-web-dynpro-abap--part-iii-aggregations-and-ddic-binding-of-viewelements
I hope it helps.
Regards
Arjun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.