cancel
Showing results for 
Search instead for 
Did you mean: 

dynamically creating readio buttons and buttons in the view

Former Member
0 Kudos

hi experts,

i have a rather tough requirement. it goes something like this. in the selection screen lets say i have one field and i enter 5 and click on execute. i should see 5 radio buttons in a radio button group with 1. 2, 3, 4 and 5 as the respective text for each radio button. this is not all :). when i select the radio button 1 i should see a button appearing on the screen and if i select 4 i should 4 buttons with some text on it, like wise with 2 ,3 and 5. is this possible to do in ABAP webdynpro?

thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Sudhakar,

I am not sure if you would like to review the design of the user interface again.

Nevertheless, In order to implement the same, you would need to do insert ui elements dynamically.

Just for example to implement firs part.

You need to read the no of radio buttons and then use a counter or may be use do statement and then execute the code something like

DATA: l_root_cnt TYPE REF TO cl_wd_uielement_container,

l_text_view TYPE REF TO cl_wd_text_view,

l_flow_data TYPE REF TO cl_wd_flow_data.

  • Check whether the method is called for the first time

IF first_time = abap_true.

  • Get the reference for thr ROOTUIELEMENTCONTAINER

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

  • Call the method(generally starts with word new) of the corresponding class(UI specific)

here I have used textview, you can replace it with dropdrown UI element.

l_text_view = cl_wd_text_view=>new_text_view( id = 'TEXT_VIEW_ID'

text = 'YOUR TEXT' ).

l_root_cnt->add_child( l_text_view ).

  • Decide on the layout property of the UI Element.

l_flow_data = cl_wd_flow_data=>new_flow_data( element = l_text_view ).

ENDIF.

You need to implement a logic to concatenate and generate the id .

Hope it helps.

Regards

Anurag Chopra

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Although you can generate the radio buttons dynamically in the WDDOMODIFYVIEW, it isn't really necessary. Using the RadioButtonGroupByIndex UI element you base the actual number and details of the radiobuttons output at runtime upon the number of elements in the bound context node (and of course the details like text come from the context elements as well).

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d7/f08841e3af1609e10000000a155106/frameset.htm

Why use code generated UI elements (which is more difficult to maintain) when you can build them based upon the context data.

Likewise you could do the same with the buttons. You could place the button UI element within a rowRepeater. The number buttons (and their details) will then come from the number of elements of the bound context to the rowRepeater. This works much the same as the above example.

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d7/f08841e3af1609e10000000a155106/frameset.htm

SAP has created these UI element constructs specifically so people don't have to use dynamic UI coding in the WDDOMODIFYVIEW.

Former Member
0 Kudos

Hello Thomas,

Thank you for correcting me,,:). we can definately limit the things which we need to execute at runtime.

Regards

Anurag Chopra

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Check this wiki link

http://wiki.sdn.sap.com/wiki/display/WDABAP/CreatingUIElementsDynamicallyinAbapWebdynpro+Application

Also search SCN, you will get lots of threads dealing with dynamic creation of UI elements.

Regards,

Runal.

Former Member
0 Kudos

hi

i searched SDN especially for radio button generation dynamically, but could not get correct answer. i know the number of radio buttons only during the run time and i need to put them under a radio button group, so that user only selected one at a time.

thanks