-
Notifications
You must be signed in to change notification settings - Fork 0
/
YCL_SHOW_SALV_INS
294 lines (221 loc) · 9.87 KB
/
YCL_SHOW_SALV_INS
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
class YCL_SHOW_SALV_INS definition
public
abstract
create public .
public section.
methods SHOW_SALV
importing
!IV_TITLE type LVC_TITLE
!IV_REPORT type SYREPID
!IV_VARIANT type SLIS_VARI optional
!IV_HANDLE type SLIS_HANDL optional
!IR_SALV type ref to DATA
!IT_COL_SETTING type YCOL_SETTING_T optional
!IV_PFSTATUS type SYPFKEY optional .
methods ON_LINK_CLICK
for event LINK_CLICK of CL_SALV_EVENTS_TABLE
importing
!ROW
!COLUMN .
methods ON_USER_COMMAND
for event ADDED_FUNCTION of CL_SALV_EVENTS_TABLE
importing
!E_SALV_FUNCTION .
methods GET_DATA
returning
value(RO_DATA) type ref to DATA .
methods GET_SALV
returning
value(RO_SALV_TABLE) type ref to CL_SALV_TABLE .
PROTECTED SECTION.
private section.
data GO_SALV_TABLE type ref to CL_SALV_TABLE .
data GO_DATA type ref to DATA .
methods SET_SALV_FRAMEWORK
importing
!IR_SALV type DATA .
methods SET_FUNCTIONS .
methods SET_COLUMNS
importing
!IT_COL_SETTING type YCOL_SETTING_T .
methods SET_DISPLAY
importing
!IV_TITLE type LVC_TITLE
!IV_REPORT type SYREPID
!IV_VARIANT type SLIS_VARI
!IV_HANDLE type SLIS_HANDL .
ENDCLASS.
CLASS YCL_SHOW_SALV_INS IMPLEMENTATION.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SHOW_SALV_INS->GET_DATA
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RO_DATA TYPE REF TO DATA
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD get_data.
ro_data = go_data.
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SHOW_SALV_INS->GET_SALV
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RO_SALV_TABLE TYPE REF TO CL_SALV_TABLE
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD get_salv.
ro_salv_table = go_salv_table.
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SHOW_SALV_INS->ON_LINK_CLICK
* +-------------------------------------------------------------------------------------------------+
* | [--->] ROW LIKE
* | [--->] COLUMN LIKE
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD on_link_click.
* method abstract
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SHOW_SALV_INS->ON_USER_COMMAND
* +-------------------------------------------------------------------------------------------------+
* | [--->] E_SALV_FUNCTION LIKE
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD on_user_command.
* method abstract
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SHOW_SALV_INS->SET_COLUMNS
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_COL_SETTING TYPE YCOL_SETTING_T
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD set_columns.
DATA:
lo_column TYPE REF TO cl_salv_column_table.
DATA(lo_columns) = go_salv_table->get_columns( ). "Get columns setting
lo_columns->set_optimize( ). "Set optimize columns
LOOP AT it_col_setting ASSIGNING FIELD-SYMBOL(<fs_col_setting>).
lo_column ?= lo_columns->get_column( <fs_col_setting>-col ).
CASE <fs_col_setting>-tech.
WHEN abap_true.
lo_column->set_technical( if_salv_c_bool_sap=>true ).
ENDCASE.
CASE <fs_col_setting>-hide.
WHEN abap_true.
lo_column->set_visible( if_salv_c_bool_sap=>false ).
ENDCASE.
CASE <fs_col_setting>-zero.
WHEN abap_true.
lo_column->set_zero( value = abap_true ).
WHEN abap_false.
lo_column->set_zero( value = abap_false ).
ENDCASE.
CASE <fs_col_setting>-hotspot.
WHEN abap_true.
TRY.
CALL METHOD lo_column->set_cell_type
EXPORTING
value = if_salv_c_cell_type=>hotspot.
CATCH cx_salv_data_error.
ENDTRY.
ENDCASE.
IF <fs_col_setting>-alignment IS NOT INITIAL.
CALL METHOD lo_column->set_alignment
EXPORTING
value = <fs_col_setting>-alignment.
ENDIF.
IF <fs_col_setting>-dec IS NOT INITIAL.
lo_column->set_decimals( value = <fs_col_setting>-dec ).
ENDIF.
* Set color
lo_column->set_color( <fs_col_setting>-color ).
ENDLOOP.
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SHOW_SALV_INS->SET_DISPLAY
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TITLE TYPE LVC_TITLE
* | [--->] IV_REPORT TYPE SYREPID
* | [--->] IV_VARIANT TYPE SLIS_VARI
* | [--->] IV_HANDLE TYPE SLIS_HANDL
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD set_display.
* Display setting
DATA(lo_display_setting) = go_salv_table->get_display_settings( ).
lo_display_setting->set_list_header( value = iv_title ). "Set SALV header title
lo_display_setting->set_striped_pattern( cl_salv_display_settings=>true ). "Colors striped
* Layout setting
DATA(lo_layout) = go_salv_table->get_layout( ).
lo_layout->set_key( VALUE salv_s_layout_key( report = iv_report
handle = iv_handle ) ).
lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
lo_layout->set_default( value = abap_true ).
IF iv_variant IS NOT INITIAL.
lo_layout->set_initial_layout( value = iv_variant ).
ENDIF.
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SHOW_SALV_INS->SET_FUNCTIONS
* +-------------------------------------------------------------------------------------------------+
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD set_functions.
DATA(lo_functions) = go_salv_table->get_functions( ).
lo_functions->set_all( if_salv_c_bool_sap=>true ).
lo_functions->set_view_lotus( abap_false ). "Lotus 123 off
lo_functions->set_graphics( abap_false ). "Graph tool off
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SHOW_SALV_INS->SET_SALV_FRAMEWORK
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_SALV TYPE DATA
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD set_salv_framework.
FIELD-SYMBOLS:
<fs_tab> TYPE ANY TABLE.
FREE:
go_data,
go_salv_table.
CLEAR:
go_data,
go_salv_table.
go_data = ir_salv.
ASSIGN ir_salv->* TO <fs_tab>.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = go_salv_table " Basis Class Simple ALV Tables
CHANGING t_table = <fs_tab> ). " Internal table to display
CATCH cx_salv_msg.
ENDTRY.
SET HANDLER:
on_link_click FOR go_salv_table->get_event( ),
on_user_command FOR go_salv_table->get_event( ).
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SHOW_SALV_INS->SHOW_SALV
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TITLE TYPE LVC_TITLE
* | [--->] IV_REPORT TYPE SYREPID
* | [--->] IV_VARIANT TYPE SLIS_VARI(optional)
* | [--->] IV_HANDLE TYPE SLIS_HANDL(optional)
* | [--->] IR_SALV TYPE REF TO DATA
* | [--->] IT_COL_SETTING TYPE YCOL_SETTING_T(optional)
* | [--->] IV_PFSTATUS TYPE SYPFKEY(optional)
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD show_salv.
* Set SALV Framework
set_salv_framework( ir_salv = ir_salv ).
* include own functions by setting own status
IF iv_pfstatus IS NOT INITIAL.
go_salv_table->set_screen_status( pfstatus = iv_pfstatus
report = iv_report
set_functions = go_salv_table->c_functions_all ).
DATA(lo_selection) = go_salv_table->get_selections( ).
lo_selection->set_selection_mode( cl_salv_selections=>multiple ).
ENDIF.
* Set default functions setting
set_functions( ).
* Set default columns setting
set_columns( it_col_setting = it_col_setting ).
* Set default display setting
set_display( iv_title = iv_title
iv_report = iv_report
iv_variant = iv_variant
iv_handle = iv_handle ).
* Display SALV
go_salv_table->display( ).
ENDMETHOD.
ENDCLASS.