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
Now map the same node in context of the view.
Create a UI Element Table in layout of the main view
Bind the table data source property to the context node ‘RADIO’ of the main view
Now create binding for the table on right clicking on Table UI Element and bind the context as follows
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
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.
Save the application and execute the same with created URL.
Above screen will be displayed with some default values specified in the program.
0 Comments:
Post a Comment