-
Notifications
You must be signed in to change notification settings - Fork 0
/
DEMO_DYNPRO.ABAP
363 lines (286 loc) · 9.6 KB
/
DEMO_DYNPRO.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
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
*&---------------------------------------------------------------------*
*& Report S_SCREEN_PAINTER_DEMO *
*&---------------------------------------------------------------------*
REPORT s_screen_painter_demo.
*----------------------------------------------------------------------
* Global data declarations
*----------------------------------------------------------------------
CONTROLS: tabcon TYPE TABLEVIEW USING SCREEN 0100.
CONTROLS: ts TYPE TABSTRIP.
DATA: g_tabcon_lines LIKE sy-loopc.
DATA: input(22) TYPE c,
check1(1) TYPE c,
check2(1) TYPE c,
radio1(1) TYPE c,
radio2(1) TYPE c,
radio3(1) TYPE c,
radio4(1) TYPE c,
ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.
DATA: BEGIN OF tc_line,
flag(1),
sp1(10),
sp2(10),
sp3(10),
sp4(10),
END OF tc_line.
DATA tcon LIKE TABLE OF tc_line WITH HEADER LINE.
DATA html TYPE REF TO cl_gui_html_viewer.
DATA container TYPE REF TO cl_gui_custom_container.
* Classes
CLASS screen_100 DEFINITION.
PUBLIC SECTION.
CLASS-METHODS handle_push_button.
ENDCLASS.
*
CLASS screen_100 IMPLEMENTATION.
METHOD handle_push_button.
MESSAGE i888(sabapdemos) WITH text-010.
SET SCREEN 100.
ENDMETHOD.
ENDCLASS.
*----------------------------------------------------------------------
* Processing blocks
*----------------------------------------------------------------------
START-OF-SELECTION.
CALL SCREEN 100.
* PBO modules
MODULE status_0100 OUTPUT.
SET TITLEBAR 'TIT_100'.
SET PF-STATUS 'SCREEN_100'.
input = 'Eingabefeld'.
CREATE OBJECT container
EXPORTING
container_name = 'CUSTOM_AREA'.
CREATE OBJECT html
EXPORTING
parent = container.
CALL METHOD html->show_url
EXPORTING
url = 'http://www.sap.com'.
ENDMODULE.
* PAI modules
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BACK'.
...
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
LEAVE SCREEN.
WHEN 'PRESS'.
CALL METHOD screen_100=>handle_push_button.
ENDCASE.
ENDMODULE.
* Callback routine for context menu
FORM on_ctmenu_input USING l_menu TYPE REF TO cl_ctmenu.
CALL METHOD l_menu->add_function
EXPORTING
fcode = 'PRESS'
text = text-020.
ENDFORM.
* Dialog Modules
MODULE tabcon_change_tc_attr OUTPUT.
DESCRIBE TABLE tcon LINES tabcon-lines.
ENDMODULE.
MODULE tabcon_get_lines OUTPUT.
g_tabcon_lines = sy-loopc.
ENDMODULE.
MODULE tabcon_modify INPUT.
MODIFY tcon
INDEX tabcon-current_line.
ENDMODULE.
MODULE tabcon_mark INPUT.
MODIFY tcon
INDEX tabcon-current_line
TRANSPORTING flag.
ENDMODULE.
MODULE tabcon_user_command INPUT.
PERFORM user_ok_tc USING 'TABCON'
'TCON'
'FLAG'
CHANGING ok_code.
ENDMODULE.
*Table Control Forms
FORM user_ok_tc USING p_tc_name TYPE dynfnam
p_table_name
p_mark_name
CHANGING p_ok LIKE sy-ucomm.
DATA: l_ok TYPE sy-ucomm,
l_offset TYPE i.
SEARCH p_ok FOR p_tc_name.
IF sy-subrc <> 0.
EXIT.
ENDIF.
l_offset = STRLEN( p_tc_name ) + 1.
l_ok = p_ok+l_offset.
CASE l_ok.
WHEN 'INSR'. "insert row
PERFORM fcode_insert_row USING p_tc_name
p_table_name.
CLEAR p_ok.
WHEN 'DELE'. "delete row
PERFORM fcode_delete_row USING p_tc_name
p_table_name
p_mark_name.
CLEAR p_ok.
WHEN 'P--' OR "top of list
'P-' OR "previous page
'P+' OR "next page
'P++'. "bottom of list
PERFORM compute_scrolling_in_tc USING p_tc_name
l_ok.
CLEAR p_ok.
WHEN 'MARK'. "mark all filled lines
PERFORM fcode_tc_mark_lines USING p_tc_name
p_table_name
p_mark_name .
CLEAR p_ok.
WHEN 'DMRK'. "demark all filled lines
PERFORM fcode_tc_demark_lines USING p_tc_name
p_table_name
p_mark_name .
CLEAR p_ok.
ENDCASE.
ENDFORM. " USER_OK_TC
FORM fcode_insert_row
USING p_tc_name TYPE dynfnam
p_table_name .
DATA l_lines_name LIKE feld-name.
DATA l_selline LIKE sy-stepl.
DATA l_lastline TYPE i.
DATA l_line TYPE i.
DATA l_table_name LIKE feld-name.
FIELD-SYMBOLS <tc> TYPE cxtab_control.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
FIELD-SYMBOLS <lines> TYPE i.
ASSIGN (p_tc_name) TO <tc>.
l_table_name = p_table_name && '[]'. "table body
ASSIGN (l_table_name) TO <table>. "not headerline
l_lines_name = 'G_' && p_tc_name && '_LINES'.
ASSIGN (l_lines_name) TO <lines>.
GET CURSOR LINE l_selline.
IF sy-subrc <> 0. " append line to table
l_selline = <tc>-lines + 1.
IF l_selline > <lines>.
<tc>-top_line = l_selline - <lines> + 1 .
l_line = 1.
ELSE.
<tc>-top_line = 1.
l_line = l_selline.
ENDIF.
ELSE. " insert line into table
l_selline = <tc>-top_line + l_selline - 1.
l_lastline = l_selline + <lines> - 1.
IF l_lastline <= <tc>-lines.
<tc>-top_line = l_selline.
l_line = 1.
ELSEIF <lines> > <tc>-lines.
<tc>-top_line = 1.
l_line = l_selline.
ELSE.
<tc>-top_line = <tc>-lines - <lines> + 2 .
l_line = l_selline - <tc>-top_line + 1.
ENDIF.
ENDIF.
INSERT INITIAL LINE INTO <table> INDEX l_selline.
<tc>-lines = <tc>-lines + 1.
SET CURSOR LINE l_line.
ENDFORM. " FCODE_INSERT_ROW
FORM fcode_delete_row
USING p_tc_name TYPE dynfnam
p_table_name
p_mark_name .
DATA l_table_name LIKE feld-name.
FIELD-SYMBOLS <tc> TYPE cxtab_control.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
FIELD-SYMBOLS <wa>.
FIELD-SYMBOLS <mark_field>.
ASSIGN (p_tc_name) TO <tc>.
l_table_name = p_table_name && '[]'. "table body
ASSIGN (l_table_name) TO <table>. "not headerline
DESCRIBE TABLE <table> LINES <tc>-lines.
LOOP AT <table> ASSIGNING <wa>.
ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
IF <mark_field> = 'X'.
DELETE <table> INDEX syst-tabix.
IF sy-subrc = 0.
<tc>-lines = <tc>-lines - 1.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " FCODE_DELETE_ROW
FORM compute_scrolling_in_tc USING p_tc_name
p_ok.
DATA l_tc_new_top_line TYPE i.
DATA l_tc_name LIKE feld-name.
DATA l_tc_lines_name LIKE feld-name.
DATA l_tc_field_name LIKE feld-name.
FIELD-SYMBOLS <tc> TYPE cxtab_control.
FIELD-SYMBOLS <lines> TYPE i.
ASSIGN (p_tc_name) TO <tc>.
l_tc_lines_name = 'G_' && p_tc_name && '_LINES'.
ASSIGN (l_tc_lines_name) TO <lines>.
IF <tc>-lines = 0.
l_tc_new_top_line = 1.
ELSE.
CALL FUNCTION 'SCROLLING_IN_TABLE'
EXPORTING
entry_act = <tc>-top_line
entry_from = 1
entry_to = <tc>-lines
last_page_full = 'X'
loops = <lines>
ok_code = p_ok
overlapping = 'X'
IMPORTING
entry_new = l_tc_new_top_line
EXCEPTIONS
no_entry_or_page_act = 01
no_entry_to = 02
no_ok_code_or_page_go = 03
OTHERS = 99.
ENDIF.
GET CURSOR FIELD l_tc_field_name
AREA l_tc_name.
IF syst-subrc = 0.
IF l_tc_name = p_tc_name.
SET CURSOR FIELD l_tc_field_name LINE 1.
ENDIF.
ENDIF.
<tc>-top_line = l_tc_new_top_line.
ENDFORM. " COMPUTE_SCROLLING_IN_TC
FORM fcode_tc_mark_lines USING p_tc_name
p_table_name
p_mark_name.
DATA l_table_name LIKE feld-name.
FIELD-SYMBOLS <tc> TYPE cxtab_control.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
FIELD-SYMBOLS <wa>.
FIELD-SYMBOLS <mark_field>.
ASSIGN (p_tc_name) TO <tc>.
l_table_name = p_table_name && '[]'. "table body
ASSIGN (l_table_name) TO <table>. "not headerline
LOOP AT <table> ASSIGNING <wa>.
ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
<mark_field> = 'X'.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
FORM fcode_tc_demark_lines USING p_tc_name
p_table_name
p_mark_name .
DATA l_table_name LIKE feld-name.
FIELD-SYMBOLS <tc> TYPE cxtab_control.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
FIELD-SYMBOLS <wa>.
FIELD-SYMBOLS <mark_field>.
ASSIGN (p_tc_name) TO <tc>.
l_table_name = p_table_name && '[]'. "table body
ASSIGN (l_table_name) TO <table>. "not headerline
LOOP AT <table> ASSIGNING <wa>.
ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
<mark_field> = space.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines