Академический Документы
Профессиональный Документы
Культура Документы
As per business need there was a scenario for an ALV Report Output, It must
have functionality selecting only one row at a time. It is possible with Radio
buttons.
Below are the steps to display Radio Buttons in the output of an ALV.
a)
Include ICONS.
INCLUDE <icons>.
b) Declare an internal table with the required fields and additional field
called RADIO of type CHAR of size 4.
c)
Define a class to handle an even HOTSPOT_CLICK o trigger when we
click on the radio button icon. Definition as coded below.
* Handles the Even when user clicks on any row.
METHODS: handle_hotspot_click FOR EVENT hotspot_click
OF cl_gui_alv_grid
IMPORTING e_row_id.
d) Do the implementation for the same class to handle the event i.e. if we
select a radio button, then the already selected radio button should be
deselect and new radio button should be selected. Code as follows.
*&--------------------------------------------------------------*
CLEAR : gs_emp.
READ TABLE gt_emp INTO gs_emp
TRANSPORTING radio.
ENDIF.
ELSE .
gs_emp-radio = icon_wd_radio_button_empty.
MODIFY gt_emp INDEX sy-tabix FROM gs_emp
TRANSPORTING radio.
CLEAR gs_emp.
READ TABLE gt_emp INTO gs_emp INDEX e_row_id .
IF sy-subrc = 0.
gs_emp-radio = icon_radiobutton.
MODIFY gt_emp INDEX e_row_id FROM gs_emp
TRANSPORTING radio.
ENDIF.
ENDIF .
IMPORTING
rc
.
ENDMETHOD.
"handle_hotspot_click
e)
Update the RADIO button with empty radio button in the internal table.
Code as follows.
LOOP AT gt_emp INTO gs_emp.
gs_emp-radio = icon_wd_radio_button_empty.
MODIFY gt_emp FROM gs_emp TRANSPORTING radio.
ENDLOOP.
f)
While preparing the field catalogue, Prepare field catalogue for that
additional field RADIO as coded below.
ls_fieldcat-reptext
= 'Radio Button'.
ls_fieldcat-fieldname = 'RADIO'.
ls_fieldcat-ref_table = 'gt_emp'.
ls_fieldcat-icon
= 'X'.
ls_fieldcat-hotspot
= 'X'.
ls_fieldcat-col_pos
= '1'.
"Icons
"Hotspot(Hand Symbol)
g) Refresh the grid, Perform REFRESH action when the radio button is
selected.
* Define local data
DATA:ls_stable TYPE lvc_s_stbl.
ls_stable-row = abap_true.
ls_stable-col = abap_true.
= 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
h)