Está en la página 1de 12

Crear una nueva aplicacin para la siguiente demostracin

Dentro del editor de la vista en la pestaa Contexto creamos un nodo RadioG y una vista de
texto en la vista de control.

Seleccionamos capturamos el nombre de nuestro radio botn y en el apartado diccionario de


datos capturamos la estructura EKKO despus presionamos el botn ADD ATRIBUTE FROM
ESTRUCTURE y tomamos el campo EBELN.
Creamos el atributo textview
En la pestaa layout inserte un nuevo elemento de interfaz de usuario de tipo GROUP, CAPTION,
RADIOBUTTONGROUPBYINDEX y Textview en ROOTUIELEMENTCONTAINER y asigne las
propiedades en el dado a continuacin.

Introduzca el elemento Grupo de interfaz de usuario y establezca las siguientes propiedades:

design: sapcolor

width: 100%

Caption: Ejemplo de escenario


Bajo el grupo vamos a crear el textview
Vincular el texto al atributo creado antes.
Dentro del grupo agregamos un elemento RADIOBUTTONGROUPBYINDEX.

Vincular con el nodo de contexto MAIN de RADIOGROUP


Agregar evento OnSelect de nuestro RBINDEX
Ir a la pestaa mtodos de la vista main y dar doble clic en el mtodo WDDOINIT e introducir el
siguiente cdigo.

method WDDOINIT.

data : v_element type ref to if_wd_context_element,


items_node type ref to if_wd_context_node,
v_index type i,
v_text type string,
itemlist type standard table of if_main=>element_radiog,
w_list like line of itemlist.

* Appending elements to "itemList"


w_list-ebeln = 'Blue'.
append w_list to itemList.
w_list-ebeln = 'Yellow'.
append w_list to itemList.
w_list-ebeln = 'Red'.
append w_list to itemList.
w_list-ebeln = 'Magenta'.
append w_list to itemList.
w_list-ebeln = 'White'.
append w_list to itemList.
w_list-ebeln = 'Black'.
append w_list to itemList.

Items_node = wd_Context->get_child_node( Name = 'RADIOG' ).


Items_node->bind_table( itemList ).
Items_node->set_lead_selection_index( 3 ).

v_index = items_node->get_lead_selection_index( ).

clear w_list.

read table itemList


into w_list
index v_Index.

v_text = w_list-ebeln.
wd_Context-
>set_Attribute( exporting value = v_Text NAME = 'TEXTVIEW' ).

endmethod.

Ir a la pestaa Actions e ingresar el siguiente cdigo en el mtodo que creamos


method ONACTIONSELECTION.

data : v_element type ref to if_wd_context_element,


items_node type ref to if_wd_context_node,
v_index type i,
v_text type string,
itemlist type standard table of if_main=>element_radiog,
w_list like line of itemlist.

Items_node = wd_Context->get_Child_Node( Name = 'RADIOG' ).


items_node->get_static_attributes_table( importing table = itemList ).
v_index = items_node->get_lead_selection_index( ).

clear w_list.
read table itemList
into w_list
index v_Index.

v_text = w_list-ebeln.
wd_Context-
>set_Attribute( exporting value = v_Text NAME = 'TEXTVIEW' ).

endmethod.

Guardar, activar y generar la aplicacin WEB DYNPRO


Ejecutamos la aplicacin

También podría gustarte