-
Notifications
You must be signed in to change notification settings - Fork 4
/
zcl_dynscreen_radiobutton.clas.abap
152 lines (123 loc) · 5.26 KB
/
zcl_dynscreen_radiobutton.clas.abap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
CLASS zcl_dynscreen_radiobutton DEFINITION PUBLIC INHERITING FROM zcl_dynscreen_io_element FINAL CREATE PUBLIC
GLOBAL FRIENDS zcl_dynscreen_radiobutton_grp.
PUBLIC SECTION.
METHODS:
constructor IMPORTING io_parent TYPE REF TO zcl_dynscreen_radiobutton_grp
iv_text TYPE textpooltx OPTIONAL
RAISING zcx_dynscreen_type_error
zcx_dynscreen_incompatible
zcx_dynscreen_too_many_elems,
set_generic_type REDEFINITION,
set_type REDEFINITION,
set_value REDEFINITION.
PROTECTED SECTION.
METHODS:
add REDEFINITION,
generate_open REDEFINITION,
generate_close REDEFINITION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_dynscreen_radiobutton IMPLEMENTATION.
METHOD add.
* ---------------------------------------------------------------------
" radiobuttons have no children
RAISE EXCEPTION TYPE zcx_dynscreen_incompatible
EXPORTING
parent_class = me
incompatible_class = io_screen_element.
* ---------------------------------------------------------------------
ENDMETHOD.
METHOD constructor.
* ---------------------------------------------------------------------
" io_parent of super class has type zcl_dynscreen_screen_base
" which is incompatible zcl_dynscreen_radiobutton_grp
" -> pass initial variable to io_parent of super class
" -> and add me afterwards
super->constructor( io_parent = VALUE #( )
iv_type = 'ABAP_BOOL'
iv_text = iv_text ).
* ---------------------------------------------------------------------
io_parent->add( me ).
* ---------------------------------------------------------------------
ENDMETHOD.
METHOD generate_close.
* ---------------------------------------------------------------------
* ---------------------------------------------------------------------
ENDMETHOD.
METHOD generate_open.
* ---------------------------------------------------------------------
DATA:
lv_default_value TYPE string.
* ---------------------------------------------------------------------
IF mv_value IS NOT INITIAL.
lv_default_value = ` ` && mc_syn-default && ` ` && mc_syn-sq && get_value( mc_conv_cast ) && mc_syn-sq.
ENDIF.
* ---------------------------------------------------------------------
DATA(lo_rb_grp) = CAST zcl_dynscreen_radiobutton_grp( get_parent( ) ).
* ---------------------------------------------------------------------
IF lo_rb_grp->get_first_radiobutton( )->get_id( ) = mv_id.
DATA(lv_usercommand) = mc_syn-ucomm && ` ` && mc_syn-ucm_prefix && lo_rb_grp->get_id( ).
ELSE.
lv_usercommand = ''.
ENDIF.
* ---------------------------------------------------------------------
APPEND
mc_syn-param && ` ` && mc_syn-var_prefix && mv_id && ` ` && mc_syn-type && ` ` && mv_type && ` ` &&
mc_syn-radiob && ` ` && lo_rb_grp->get_id( ) && lv_default_value && ` ` && lv_usercommand &&'.'
TO mt_source.
* ---------------------------------------------------------------------
ENDMETHOD.
METHOD set_generic_type.
* ---------------------------------------------------------------------
" not supported for radiobuttons
RAISE EXCEPTION TYPE zcx_dynscreen_type_error
EXPORTING
textid = zcx_dynscreen_type_error=>type_change_not_supported
parent_class = me.
* ---------------------------------------------------------------------
ENDMETHOD.
METHOD set_type.
* ---------------------------------------------------------------------
" not supported for radiobuttons
RAISE EXCEPTION TYPE zcx_dynscreen_type_error
EXPORTING
textid = zcx_dynscreen_type_error=>type_change_not_supported
parent_class = me.
* ---------------------------------------------------------------------
ENDMETHOD.
METHOD set_value.
* ---------------------------------------------------------------------
" only either iv_value or iv_value_str are allowed to be supplied
" only abap_true and abap_false are allowed values
IF iv_value IS SUPPLIED
AND iv_value_str IS NOT SUPPLIED.
IF iv_value <> abap_true
AND iv_value <> abap_false.
RAISE EXCEPTION TYPE zcx_dynscreen_value_error
EXPORTING
textid = zcx_dynscreen_value_error=>invalid_value
value = iv_value
parent_class = me.
ENDIF.
ELSEIF iv_value IS NOT SUPPLIED
AND iv_value_str IS SUPPLIED.
IF iv_value_str <> abap_true
OR iv_value_str <> abap_false.
RAISE EXCEPTION TYPE zcx_dynscreen_value_error
EXPORTING
textid = zcx_dynscreen_value_error=>invalid_value
value = iv_value_str
parent_class = me.
ENDIF.
ELSE.
RAISE EXCEPTION TYPE zcx_dynscreen_value_error
EXPORTING
textid = zcx_dynscreen_value_error=>no_value_provided.
ENDIF.
* ---------------------------------------------------------------------
super->set_value( iv_conversion = iv_conversion
iv_value = iv_value
iv_value_str = iv_value_str ).
* ---------------------------------------------------------------------
ENDMETHOD.
ENDCLASS.