Hi, I provide training in SAP UI5. Also feel free to checkout my new web page https://saptechblog.com
Webdynpro ABAP

Table with Radio button

 

Courtesy: Document Prepared by  Prajakta Bhivare (Enteg Infotech PVT ltd)

Create the webdynpro component with proper credentials.

1.       Give the webdynpro component name starting from ‘Z’ or ‘Y’ as we are going for custom development

2.       Provide package and transport request number.

Go to component controller’s context, and crate a node

clip_image001clip_image003clip_image005

Now map the same node in context of the view.

clip_image007

Create a UI Element Table in layout of the main view

clip_image009

Bind the table data source property  to the context node ‘RADIO’ of the main view

clip_image012

Now create binding for the table on right clicking on Table UI Element and bind the context as follows

clip_image014

clip_image016

 

 

Write following code in WDDOINIT method

METHOD wddoinit .

 
DATA : node TYPE REF TO if_wd_context_node,   " Object reference to the
         it_data
TYPE ig_componentcontroller=>elements_radio,
         wa_data
LIKE LINE OF it_data.

  wa_data-name =
'Sales Order'.
  wa_data-selected_key =
'a'.
  wa_data-accepted =
' '.
  wa_data-deny =
' '.

 
APPEND wa_data
TO it_data.
 
CLEAR wa_data.

  wa_data-name =
'Purchase order'.
  wa_data-selected_key =
'a'.
  wa_data-accepted =
' '.
  wa_data-deny =
' '.

 
APPEND wa_data
TO it_data.
 
CLEAR wa_data.

  wa_data-name =
'Purchase Requisition'.
  wa_data-selected_key =
'b'.
  wa_data-accepted =
' '.
  wa_data-deny =
' '.

 
APPEND wa_data
TO it_data.
 
CLEAR wa_data.


  node = wd_context->get_child_node( name =
'RADIO').
  node->bind_table( it_data ).
ENDMETHOD.

 

Create button to handle radio button selection result

clip_image018

And write following code in event_handler method

METHOD onactionupdate .

 
DATA : item_node TYPE REF TO
if_wd_context_node,
         it_radio
TYPE
if_main=>elements_radio,
         wa_radio
LIKE LINE OF
it_radio.

  item_node = wd_context->get_child_node( name =
'RADIO'
).
  item_node->get_static_attributes_table(
IMPORTING table
= it_radio ).

 
LOOP AT it_radio INTO
wa_radio.
   
CLEAR
: wa_radio-accepted, wa_radio-deny.

   
IF wa_radio-selected_key = 'a'
.
      wa_radio-accepted =
'X'
.
   
ELSEIF wa_radio-selected_key = 'b'
.
      wa_radio-deny =
'X'
.
    ENDIF.

   
MODIFY it_radio FROM wa_radio INDEX
sy-index.

  ENDLOOP.

  item_node->bind_table( it_radio ).
ENDMETHOD.

 

To display result of the action on radio buttons, create another Table UI Element with the same number of columns as we created before.

clip_image020

 

Save the application and execute the same with created URL.

clip_image022

Above screen will be displayed with some default values specified in the program.

 

About Arun

0 Comments:

Post a Comment

Powered by Blogger.