Header Ads

Creating Radio Buttons in the Web UI


We would like to create some Z-fields on CUSTOMER_H as radio buttons:
Solution:
We need to use the P_GETTER method of the EEWB ZZ field to define:
i) the field type as radio button,
ii) the radio button group,
iii) The way radio buttons should be arranged (horizontally or vertically). If we put no. of cols = 1, then these will be arranged vertically.
We need to use V_GETTER of the same ZZ field to:
Assign the key & value to the radio buttons (coding is similar as for dropdowns).
Following is the code:
*method GET_P_ZZCUSTOMER_H0101.*

CASE iv_property.
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
rv_value = cl_bsp_dlc_view_descriptor=>field_type_radio.
WHEN if_bsp_wd_model_setter_getter=>fp_radio_cols.
rv_value = 3.
WHEN if_bsp_wd_model_setter_getter=>fp_group.
rv_value = 'R1'.

ENDCASE.

endmethod.
*method GET_V_ZZCUSTOMER_H0101.*
DATA: lt_ddlb TYPE bsp_wd_dropdown_table,
ls_ddlb TYPE bsp_wd_dropdown_line.


IF GR_DDLB_FIELD0101 IS NOT BOUND.
CREATE OBJECT GR_DDLB_FIELD0101
EXPORTING
iv_source_type = 'T'.

clear : ls_ddlb.
ls_ddlb-key = '1'.
ls_ddlb-value = 'P1'.
append ls_ddlb to lt_ddlb.

clear : ls_ddlb.
ls_ddlb-key = '2'.
ls_ddlb-value = 'P2'.
append ls_ddlb to lt_ddlb.

clear : ls_ddlb.
ls_ddlb-key = '3'.
ls_ddlb-value = 'P3'.
append ls_ddlb to lt_ddlb.

GR_DDLB_FIELD0101->set_selection_table( lt_ddlb ).

ENDIF.

rv_valuehelp_descriptor = GR_DDLB_FIELD0101.

endmethod.
Say the field label of the field ZZCUSTOMER_H0101 is "Grade", then it will show in the UI as below:
Grade () P1 () P2 () P3
() = radio button.
Powered by Blogger.