Web Dynpro – Creating a Radio Button

Home / SAP / ABAP Coding / Web Dynpro – Creating a Radio Button

Well, I’m stilling hanging out in Web Dynpro land.  I found a new enhancement that Rapier 1.0 really needed.  So here I am again.  This time I had to focus on creating a radio button, because I wanted a customer to be able to select either an existing customer, or create a new one.  IN my brain, a radio button was a nice easy solution…  right???  As always, things are more complicated than I expected.  ha ha ha.  Well, here’s how it works.

You’ll need a context element that will hold the texts for the radio buttons.  This will dynamically determine the number of radio buttons displayed.  To make it work, you’ll need a node and an attribute.  The attribute should just be a string.  Be sure to add a supply function to the node.  This is how the texts will get populated.  See below for the code.

In the layout, create yourself a new element.  I used the RadioButtonGroupByIndex element.  I had a very defined set of values (for this example, 2) so that made life nice an easy.  Inside the element, you need to set a few things…  First, ColCount, this is the number of columns that will be used to display the radiobutton.  Second, texts…  this is a table that contains the texts.  Use the context node you created above.  Third, you’ll want an action for on select.  This will determine what happens when you select a radio button.

Now for some code.  First, you’ll need to populate the radio button text.  In the supply function you assigned in the context node, add something like the following code.

data : it type table of if_v_rp_user_create=>element_cust_method,
wa like line of it.
DATA lo_nd_app TYPE REF TO if_wd_context_node.

wa-text = ‘radio 1’.
append wa to it.
wa-text = ‘radio 2’.
append wa to it.
node->bind_table( it ).

So, those are the basic…

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike

Leave a Reply

Your email address will not be published. Required fields are marked *