-
Notifications
You must be signed in to change notification settings - Fork 18
/
SDE_702.abap
2598 lines (2302 loc) · 92.2 KB
/
SDE_702.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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*&---------------------------------------------------------------------*
*& Report YS_SDE - Simple Data Explorer
*& version: alpha 0.5.178.145
*& Written by Yurii Sychov
*& e-mail: ysichov@gmail.com
*& skype: ysichov
*& blog: https://ysychov.wordpress.com/blog/
*& LinkedIn: https://www.linkedin.com/in/ysychov/
*&---------------------------------------------------------------------*
report ys_sde.
class lcl_data_receiver definition deferred.
class lcl_data_transmitter definition deferred.
types:
begin of selection_display_s,
ind type i,
field_label type lvc_fname,
int_type(1),
inherited type aqadh_type_of_icon,
emitter type aqadh_type_of_icon,
sign type tvarv_sign,
opti type tvarv_opti,
option_icon type aqadh_type_of_icon,
low type aqadh_range_value,
high type aqadh_range_value,
more_icon type aqadh_type_of_icon,
range type aqadh_t_ranges,
name type reptext,
element type text60,
domain type text60,
datatype type string,
length type i,
transmitter type ref to lcl_data_transmitter,
receiver type ref to lcl_data_receiver,
color type lvc_t_scol,
style type lvc_t_styl,
end of selection_display_s,
begin of t_sel_row,
sign type tvarv_sign,
opti type tvarv_opti,
option_icon type aqadh_type_of_icon,
low type aqadh_range_value,
high type aqadh_range_value,
more_icon type aqadh_type_of_icon,
range type aqadh_t_ranges,
end of t_sel_row.
data: gt_sel type table of selection_display_s.
field-symbols: <g_str> type any.
selection-screen begin of screen 101.
parameters: gv_tname type tabname visible length 15 matchcode object dd_bastab_for_view.
selection-screen end of screen 0101.
"Begin of INCLUDE YS_SDE_CLASSES.
*----------------------------------------------------------------------*
* CLASS lcl_plugins DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_plugins definition.
public section.
types: begin of t_field_links,
tab type tabname,
field type fieldname,
rtab type tabname,
rfield type fieldname,
const type aqadh_range_value,
end of t_field_links,
begin of t_el_links,
element type tablename,
rtab type tabname,
rfield type fieldname,
end of t_el_links.
class-data: mt_field_links type table of t_field_links,
mt_el_links type table of t_el_links.
class-methods: init.
endclass. "lcl_plugins DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_plugins IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_plugins implementation.
method init.
"data elements links
* mt_el_links = VALUE #(
* ( element = 'PERSNO' rtab = 'PA0002' rfield = 'PERNR' )
* ( element = 'HROBJID' rtab = 'HRP1000' rfield = 'OBJID' )
* ( element = 'HROBJID' rtab = 'HRP1000' rfield = 'OTYPE' )
* ( element = 'LGART' rtab = 'T512W' rfield = 'LGART' )
* ).
"field to field links
* mt_field_links = VALUE #(
* ( tab = 'PA0001' field = 'PLANS' rtab = 'HRP1000' rfield = 'OTYPE' const = 'S' )
* ( tab = 'PA0001' field = 'PLANS' rtab = 'HRP1000' rfield = 'OBJID' )
* ( tab = 'PA0001' field = 'ORGEH' rtab = 'HRP1000' rfield = 'OTYPE' const = 'O' )
* ( tab = 'PA0001' field = 'ORGEH' rtab = 'HRP1000' rfield = 'OBJID' )
* ( tab = 'PA0001' field = 'STELL' rtab = 'HRP1000' rfield = 'OBJID' const = 'C' )
* ( tab = 'PA0001' field = 'STELL' rtab = 'HRP1000' rfield = 'OBJID' )
* ( tab = 'HRP1000' field = 'OTYPE' rtab = 'HRP1001' rfield = 'OTYPE' )
* ( tab = 'HRP1000' field = 'OBJID' rtab = 'HRP1001' rfield = 'OBJID' )
* ( tab = 'HRP1001' field = 'OTYPE' rtab = 'HRP1000' rfield = 'OTYPE' )
* ( tab = 'HRP1001' field = 'OBJID' rtab = 'HRP1000' rfield = 'OBJID' )
* ( tab = 'HRP1001' field = 'SCLAS' rfield = 'OTYPE' )
* ( tab = 'HRP1001' field = 'SOBID' rfield = 'OBJID' )
* ( tab = 'HRP1002' field = 'TABNR' rtab = 'HRT1002' rfield = 'TABNR' )
* ( tab = 'PA2006' field = 'QUONR' rtab = 'PTQUODED' rfield = 'QUONR' )
* ( tab = 'PTQUODED' field = 'QUONR' rtab = 'PA2006' rfield = 'QUONR' )
* ( tab = 'PTQUODED' field = 'DOCNR' rtab = 'PA2001' rfield = 'DOCNR' )
* ).
endmethod. "init
endclass. "lcl_plugins IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS lcl_ddic DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_ddic definition.
public section.
class-methods: get_text_table importing i_tname type tabname
exporting e_checkfield type fieldname
e_tab type tabname.
endclass. "lcl_ddic DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_ddic IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_ddic implementation.
method get_text_table.
call function 'DDUT_TEXTTABLE_GET'
exporting
tabname = i_tname
importing
texttable = e_tab
checkfield = e_checkfield.
endmethod. "get_text_table
endclass. "lcl_ddic IMPLEMENTATION
class lcl_table_viewer definition deferred.
class lcl_box_handler definition deferred.
class lcl_sel_opt definition deferred.
*----------------------------------------------------------------------*
* CLASS LCL_DD_DATA DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_dd_data definition."drag&drop data
public section.
data: m_row type i,
m_column type lvc_s_col.
endclass. "lcl_dd_data DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_DRAGDROP DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_dragdrop definition.
public section.
class-methods:
drag for event ondrag of cl_gui_alv_grid
importing es_row_no e_dragdropobj e_row e_column ,
drop for event ondrop of cl_gui_alv_grid
importing es_row_no e_dragdropobj e_row.
endclass. "lcl_dragdrop DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_SQL DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_sql definition.
public section.
class-methods:
exist_table importing i_tab like gv_tname returning value(e_subrc) like sy-subrc.
endclass. "lcl_sql DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_SQL IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_sql implementation.
method exist_table.
select count( * ) from dd02l
where tabname = i_tab
and ( tabclass = 'TRANSP' or tabclass = 'CLUSTER' ).
e_subrc = sy-dbcnt.
endmethod. "exist_table
endclass. "lcl_sql IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS lcl_rtti DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_rtti definition.
public section.
class-methods:
create_table_by_name importing i_tname type tabname changing c_table type ref to data,
create_struc_handle importing i_tname type tabname exporting e_t_comp type abap_component_tab e_handle type ref to cl_abap_structdescr.
endclass. "lcl_rtti DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_rtti IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_rtti implementation.
method create_struc_handle.
data: l_texttab type tabname,
lo_texttab type ref to cl_abap_structdescr,
ls_comp type abap_componentdescr,
lt_components type abap_component_tab,
lt_field_info type table of dfies,
ls_field type dfies.
lcl_ddic=>get_text_table( exporting i_tname = i_tname importing e_tab = l_texttab ).
e_handle ?= cl_abap_typedescr=>describe_by_name( i_tname ).
if l_texttab is not initial.
lo_texttab ?= cl_abap_typedescr=>describe_by_name( l_texttab ).
data: l_descr like line of cl_abap_structdescr=>components.
loop at e_handle->components into l_descr.
ls_comp-name = l_descr-name.
ls_comp-type ?= e_handle->get_component_type( ls_comp-name ).
append ls_comp to lt_components.
endloop.
loop at lo_texttab->components into l_descr.
call function 'DDIF_FIELDINFO_GET'
exporting
tabname = l_texttab
fieldname = l_descr-name
langu = sy-langu
tables
dfies_tab = lt_field_info
exceptions
not_found = 1
internal_error = 2
others = 3.
read table lt_field_info into ls_field index 1.
if ls_field-keyflag = abap_false.
ls_comp-name = l_texttab && '_' && l_descr-name.
ls_comp-type ?= lo_texttab->get_component_type( l_descr-name ).
append ls_comp to lt_components.
append ls_comp to e_t_comp.
endif.
endloop.
e_handle = cl_abap_structdescr=>create( lt_components ).
endif.
endmethod. "create_struc_handle
method create_table_by_name.
data: lo_new_tab type ref to cl_abap_tabledescr,
lo_new_type type ref to cl_abap_structdescr.
create_struc_handle( exporting i_tname = i_tname importing e_handle = lo_new_type ).
lo_new_tab = cl_abap_tabledescr=>create(
p_line_type = lo_new_type
p_table_kind = cl_abap_tabledescr=>tablekind_std
p_unique = abap_false ).
create data c_table type handle lo_new_tab. "Create a New table type
endmethod. "create_table_by_name
endclass. "lcl_rtti IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS LCL_ALV_COMMON DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_alv_common definition.
public section.
constants: c_white(4) type x value '00000001', "white background
c_grey(4) type x value '00000003', "white background
c_green(4) type x value '00000216', "green +underline
c_blue(4) type x value '00000209', " blue font +underline
c_bold(4) type x value '00000020'.
types: begin of t_tabfields.
include type dfies.
types: empty type xfeld,
end of t_tabfields.
class-data: mt_tabfields type hashed table of t_tabfields with unique key tabname fieldname.
class-methods:
refresh importing i_obj type ref to cl_gui_alv_grid i_layout type lvc_s_layo optional,
translate_field importing i_lang type ddlanguage optional changing c_fld type lvc_s_fcat.
endclass. "lcl_alv_common DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_ALV_COMMON IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_alv_common implementation.
method refresh.
data l_stable type lvc_s_stbl.
l_stable-row = 'X'.
l_stable-col = 'X'.
if i_layout is supplied.
i_obj->set_frontend_layout( i_layout ) .
endif.
i_obj->refresh_table_display( exporting is_stable = l_stable ).
endmethod. "refresh
method translate_field.
data: lv_lang like sy-langu,
lt_field_info type table of dfies.
call function 'DDIF_FIELDINFO_GET'
exporting
tabname = c_fld-ref_table
fieldname = c_fld-fieldname
langu = lv_lang
tables
dfies_tab = lt_field_info
exceptions
not_found = 1
internal_error = 2
others = 3.
if sy-subrc = 0.
data: l_info type dfies.
read table lt_field_info index 1 into l_info.
if l_info-scrtext_l is initial and l_info-scrtext_m is initial and l_info-scrtext_s is initial.
if l_info-fieldtext is not initial.
move l_info-fieldtext to: c_fld-reptext, c_fld-scrtext_l, c_fld-scrtext_m, c_fld-scrtext_s .
else.
move l_info-fieldname to: c_fld-reptext, c_fld-scrtext_l, c_fld-scrtext_m, c_fld-scrtext_s .
endif.
else.
c_fld-scrtext_l = l_info-scrtext_l.
c_fld-scrtext_m = l_info-scrtext_m.
c_fld-scrtext_s = l_info-scrtext_s.
if l_info-reptext is not initial.
c_fld-reptext = l_info-reptext.
endif.
endif.
endif.
endmethod. "translate_field
endclass. "lcl_alv_common IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS LCL_APPL DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_appl definition.
public section.
types: begin of sign_option_icon_s,
sign type tvarv_sign,
option type tvarv_opti,
icon_name(64) type c,
icon type aqadh_type_of_icon,
end of sign_option_icon_s,
begin of t_obj,
alv_viewer type ref to lcl_table_viewer,
end of t_obj,
begin of t_lang,
spras type spras,
sptxt type sptxt,
end of t_lang .
class-data: m_option_icons type table of sign_option_icon_s,
mt_lang type table of t_lang,
mt_obj type table of t_obj, "main object table
m_ctrl_box_handler type ref to lcl_box_handler,
c_dragdropalv type ref to cl_dragdrop.
class-methods:
init_icons_table,
init_lang,
suppress_run_button,
exit.
endclass. "lcl_appl DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_DATA_TRANSMITTER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_data_transmitter definition.
public section.
events: data_changed exporting value(e_row) type t_sel_row,
col_changed exporting value(e_column) type lvc_fname.
methods: emit importing e_row type t_sel_row,
emit_col importing e_column type lvc_fname.
endclass. "lcl_data_transmitter DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_DATA_TRANSMITTER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_data_transmitter implementation.
method emit.
raise event data_changed exporting e_row = e_row.
endmethod. "emit
method emit_col.
raise event col_changed exporting e_column = e_column.
endmethod. "emit_col
endclass. "lcl_data_transmitter IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS LCL_DATA_RECEIVER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_data_receiver definition.
public section.
data: mo_transmitter type ref to lcl_data_transmitter,
lo_tab_from type ref to lcl_table_viewer,
lo_sel_to type ref to lcl_sel_opt,
m_from_field type lvc_fname,
m_to_field type lvc_fname.
methods: constructor
importing io_transmitter type ref to lcl_data_transmitter optional
io_tab_from type ref to lcl_table_viewer optional
io_sel_to type ref to lcl_sel_opt optional
i_from_field type lvc_fname optional
i_to_field type lvc_fname optional,
shut_down,
update for event data_changed of lcl_data_transmitter importing e_row,
update_col for event col_changed of lcl_data_transmitter importing e_column,
on_grid_button_click
for event button_click of cl_gui_alv_grid
importing
es_col_id
es_row_no.
endclass. "lcl_data_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_SEL_OPT DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_sel_opt definition.
public section.
data: mo_viewer type ref to lcl_table_viewer,
mo_sel_alv type ref to cl_gui_alv_grid,
mt_fcat type lvc_t_fcat,
mt_sel_tab type table of selection_display_s,
ms_layout type lvc_s_layo.
events: selection_done.
methods:
constructor importing io_viewer type ref to lcl_table_viewer io_container type ref to cl_gui_container,
raise_selection_done,
update_sel_tab,
set_value importing i_field type any i_low type any optional i_high type any optional i_clear type xfeld optional,
update_sel_row changing c_sel_row type selection_display_s.
private section.
methods:
init_fcat importing i_dd_handle type i,
handle_doubleclick FOR EVENT double_click OF cl_gui_alv_grid IMPORTING e_column es_row_no,
handle_sel_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive,
on_f4 for event onf4 of cl_gui_alv_grid
importing e_fieldname
es_row_no
er_event_data,
on_grid_button_click for event button_click of cl_gui_alv_grid
importing
es_col_id
es_row_no,
on_data_changed for event
data_changed of cl_gui_alv_grid
importing e_onf4
e_onf4_before
er_data_changed
sender,
on_data_changed_finished for event data_changed_finished of cl_gui_alv_grid
importing e_modified et_good_cells,
handle_user_command for event user_command of cl_gui_alv_grid
importing e_ucomm,
handle_context_menu_request for event context_menu_request
of cl_gui_alv_grid
importing
e_object
sender.
endclass. "lcl_sel_opt DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_TABLE_VIEWER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_table_viewer definition.
public section.
types: begin of t_column_emitter,
column type lvc_fname,
emitter type ref to lcl_data_transmitter,
end of t_column_emitter.
data: m_lang type ddlanguage,
m_tabname type tabname,
m_count type i,
mo_alv type ref to cl_gui_alv_grid,
mo_sel type ref to lcl_sel_opt,
mo_box type ref to cl_gui_dialogbox_container,
mr_table type ref to data,
mr_text_table type ref to data,
mo_splitter type ref to cl_gui_splitter_container,
mo_sel_parent type ref to cl_gui_container,
mo_alv_parent type ref to cl_gui_container,
mt_alv_catalog type lvc_t_fcat,
mt_text_components type abap_component_tab,
m_checkfield type fieldname,
mo_column_emitters type table of t_column_emitter,
mo_sel_width type i,
m_visible,
m_std_tbar type x,
m_show_empty.
methods:
constructor importing i_tname type tabname,
get_where returning value(c_where) type string,
refresh_table for event selection_done of lcl_sel_opt.
private section.
methods:
create_popup,
create_alv,
create_sel_alv,
set_header,
read_text_table,
update_texts,
read_table importing i_tabname type tabname
i_where type string
i_row_count type i optional
changing cr_tab type ref to data
c_count type i,
link importing i_str type any
i_column type any returning value(r_done) type xfeld,
create_field_cat importing i_tname type tabname returning value(et_catalog) type lvc_t_fcat,
on_f4 for event onf4 of cl_gui_alv_grid importing e_fieldname es_row_no er_event_data,
handle_tab_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive,
handle_menu_button
for event menu_button of cl_gui_alv_grid
importing e_object e_ucomm,
before_user_command for event before_user_command of cl_gui_alv_grid importing e_ucomm,
handle_doubleclick for event double_click of cl_gui_alv_grid importing e_column es_row_no,
handle_user_command
for event user_command of cl_gui_alv_grid
importing e_ucomm.
endclass. "lcl_table_viewer DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_DATA_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_data_receiver implementation.
method constructor.
lo_sel_to = io_sel_to.
m_from_field = i_from_field.
m_to_field = i_to_field.
lo_tab_from = io_tab_from.
mo_transmitter = io_transmitter.
if mo_transmitter is not initial.
if lo_tab_from is initial.
set handler me->update for io_transmitter.
else.
set handler me->update_col for io_transmitter.
endif.
else.
set handler me->update for all instances.
endif.
endmethod. "constructor
method shut_down.
if mo_transmitter is not initial.
set handler me->update for mo_transmitter activation space.
else.
set handler me->update for all instances activation space.
endif.
clear lo_sel_to.
endmethod. "shut_down
method on_grid_button_click.
field-symbols: <f_tab> type standard table,
<f_field> type any.
check m_from_field = es_col_id-fieldname.
assign lo_tab_from->mr_table->* to <f_tab>.
field-symbols <tab> type any.
read table <f_tab> index es_row_no-row_id assigning <tab>.
assign component es_col_id-fieldname of structure <tab> to <f_field>.
check lo_sel_to is not initial.
field-symbols <to> like line of lo_sel_to->mt_sel_tab.
read table lo_sel_to->mt_sel_tab assigning <to> with key field_label = m_to_field.
clear: <to>-high, <to>-opti, <to>-sign, <to>-range.
<to>-low = <f_field>.
lo_sel_to->update_sel_row( changing c_sel_row = <to> ).
if <to>-transmitter is bound.
data: ls_row type t_sel_row.
move-corresponding <to> to ls_row.
<to>-transmitter->emit( exporting e_row = ls_row ).
endif.
lcl_alv_common=>refresh( lo_sel_to->mo_sel_alv ).
lo_sel_to->raise_selection_done( ).
endmethod. "on_grid_button_click
method update.
data: l_updated.
field-symbols <to> like line of lo_sel_to->mt_sel_tab.
read table lo_sel_to->mt_sel_tab assigning <to> with key field_label = m_to_field.
if <to>-range[] = e_row-range[].
l_updated = 'X'."so as not to have an infinite event loop
endif.
move-corresponding e_row to <to>.
if <to>-transmitter is bound and l_updated is initial.
<to>-transmitter->emit( exporting e_row = e_row ).
endif.
lcl_alv_common=>refresh( lo_sel_to->mo_sel_alv ).
lo_sel_to->raise_selection_done( ).
endmethod. "update
method update_col.
data: lt_sel_row type t_sel_row.
field-symbols: <tab> type standard table,
<field> type any.
check lo_sel_to is not initial.
field-symbols <to> like line of lo_sel_to->mt_sel_tab.
read table lo_sel_to->mt_sel_tab assigning <to> with key field_label = m_to_field.
clear: <to>-sign, <to>-opti, <to>-low, <to>-high, <to>-range.
assign lo_tab_from->mr_table->* to <tab>.
field-symbols <row> type any.
loop at <tab> assigning <row>.
assign component e_column of structure <row> to <field>.
read table <to>-range with key low = <field> transporting no fields.
if sy-subrc ne 0.
data ls_range type aqadh_s_ranges.
ls_range-sign = 'I'.
ls_range-opti = 'EQ'.
ls_range-low = <field>.
append ls_range to <to>-range.
endif.
endloop.
if sy-subrc ne 0." empty column
ls_range-sign = 'I'.
ls_range-opti = 'EQ'.
ls_range-low = ''.
append ls_range to <to>-range.
endif.
field-symbols <sel> type aqadh_s_ranges.
loop at <to>-range assigning <sel>.
<to>-low = <sel>-low.
lo_sel_to->update_sel_row( changing c_sel_row = <to> ).
exit.
endloop.
move-corresponding <to> to lt_sel_row.
if <to>-transmitter is bound. " AND l_updated IS INITIAL.
<to>-transmitter->emit( exporting e_row = lt_sel_row ).
endif.
lcl_alv_common=>refresh( lo_sel_to->mo_sel_alv ).
lo_sel_to->raise_selection_done( ).
endmethod. "update_col
endclass. "lcl_data_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS LCL_BOX_HANDLER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_box_handler definition."for memory clearing
public section.
methods: on_box_close for event close of cl_gui_dialogbox_container importing sender.
endclass. "lcl_box_handler DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_BOX_HANDLER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_box_handler implementation.
method on_box_close.
data: lv_tabix like sy-tabix.
sender->free( ).
"Free Memory
field-symbols <obj> type lcl_appl=>t_obj.
loop at lcl_appl=>mt_obj assigning <obj>.
if <obj>-alv_viewer->mo_box = sender.
lv_tabix = sy-tabix.
exit.
endif.
endloop.
if sy-subrc = 0.
free <obj>-alv_viewer->mr_table.
free <obj>-alv_viewer->mo_alv.
"shutdown receivers.
if <obj>-alv_viewer->mo_sel is not initial.
data l_sel type selection_display_s.
loop at <obj>-alv_viewer->mo_sel->mt_sel_tab into l_sel.
if l_sel-receiver is bound.
l_sel-receiver->shut_down( ).
endif.
endloop.
endif.
free <obj>-alv_viewer.
delete lcl_appl=>mt_obj index lv_tabix.
endif.
endmethod. "ON_BOX_CLOSE
endclass. "lcl_box_handler
*----------------------------------------------------------------------*
* CLASS LCL_TABLE_VIEWER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_table_viewer implementation.
method constructor.
m_lang = sy-langu.
mo_sel_width = 0.
m_tabname = i_tname.
create_popup( ).
lcl_rtti=>create_table_by_name( exporting i_tname = m_tabname changing c_table = mr_table ).
create_alv( ).
create_sel_alv( ).
mo_alv->set_focus( mo_alv ).
endmethod. "constructor
method create_popup.
data: l_top type i,
l_left type i.
data l_lines type i.
l_lines = lines( lcl_appl=>mt_obj ) - 1.
l_top = 20 + 30 * ( l_lines div 5 ) + ( l_lines mod 5 ) * 50.
l_left = 350 + 300 * ( l_lines div 5 ) + ( l_lines mod 5 ) * 50.
create object mo_box
exporting
width = '800'
height = '150'
top = l_top
left = l_left
caption = m_tabname
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
event_already_registered = 6
error_regist_event = 7
others = 8.
if sy-subrc <> 0.
return.
endif.
create object mo_splitter
exporting
parent = mo_box
rows = 1
columns = 2
exceptions
others = 1.
mo_splitter->set_column_mode( mode = mo_splitter->mode_absolute ).
mo_splitter->set_column_width( id = 1 width = mo_sel_width ).
call method:
mo_splitter->get_container( exporting
row = 1
column = 1
receiving
container = mo_sel_parent ),
mo_splitter->get_container
exporting
row = 1
column = 2
receiving
container = mo_alv_parent.
if lcl_appl=>m_ctrl_box_handler is initial.
create object lcl_appl=>m_ctrl_box_handler.
endif.
set handler lcl_appl=>m_ctrl_box_handler->on_box_close for mo_box.
endmethod. "create_popup
method create_alv.
data: ls_layout type lvc_s_layo,
effect type i,
lt_f4 type lvc_t_f4,
handle_alv type i.
field-symbols: <f_tab> type any table.
create object mo_alv
exporting
i_parent = mo_alv_parent.
mt_alv_catalog = create_field_cat( m_tabname ).
assign mr_table->* to <f_tab>.
read_text_table( ).
read_table( exporting i_tabname = m_tabname i_where = get_where( ) i_row_count = 100
changing cr_tab = mr_table c_count = m_count ).
set_header( ).
ls_layout-col_opt = 'X'.
ls_layout-cwidth_opt = 'X'.
ls_layout-sel_mode = 'D'.
create object lcl_appl=>c_dragdropalv.
effect = cl_dragdrop=>move + cl_dragdrop=>copy.
call method lcl_appl=>c_dragdropalv->add
exporting
flavor = 'Line'
dragsrc = 'X'
droptarget = 'X'
effect = effect.
call method lcl_appl=>c_dragdropalv->get_handle
importing
handle = handle_alv.
ls_layout-s_dragdrop-grid_ddid = handle_alv.
set handler before_user_command
handle_user_command
handle_menu_button
handle_tab_toolbar
handle_doubleclick
lcl_dragdrop=>drag
on_f4
for mo_alv.
call method mo_alv->set_table_for_first_display
exporting
i_save = 'X'
i_default = 'X'
is_layout = ls_layout
changing
it_fieldcatalog = mt_alv_catalog
it_outtab = <f_tab>.
mo_alv->get_frontend_fieldcatalog( importing et_fieldcatalog = mt_alv_catalog ).
field-symbols <cat> type lvc_s_fcat.
loop at mt_alv_catalog assigning <cat> where scrtext_l is initial.
lcl_alv_common=>translate_field( changing c_fld = <cat> ).
endloop.
data ls_f4 type lvc_s_f4.
ls_f4-register = 'X'.
loop at mt_alv_catalog assigning <cat>.
clear <cat>-key.
ls_f4-fieldname = <cat>-fieldname .
insert ls_f4 into table lt_f4.
endloop.
mo_alv->register_f4_for_fields( it_f4 = lt_f4 ).
mo_alv->set_frontend_fieldcatalog( exporting it_fieldcatalog = mt_alv_catalog ).
mo_alv->set_frontend_fieldcatalog( exporting it_fieldcatalog = mt_alv_catalog ).
me->handle_user_command( exporting e_ucomm = 'HIDE' ).
mo_alv->set_toolbar_interactive( ).
endmethod. "create_alv
method create_sel_alv.
if mo_sel is initial.
create object mo_sel
exporting
io_viewer = me
io_container = mo_sel_parent.
set handler refresh_table for mo_sel.
else.
mo_sel->update_sel_tab( ).
endif.
endmethod. "create_sel_alv
method set_header.
data: lv_text type as4text,
lv_header(80) type c.
select single ddtext into lv_text
from dd02t
where tabname = m_tabname
and ddlanguage = m_lang.
lv_header = |{ m_tabname } - { lv_text } ({ m_count })|.
mo_box->set_caption( lv_header ).
endmethod. "set_header
method read_text_table.
data: l_tab type tabname.
field-symbols: <f_tab> type any table.
lcl_ddic=>get_text_table( exporting i_tname = m_tabname importing e_tab = l_tab ).
check l_tab is not initial.
lcl_rtti=>create_table_by_name( exporting i_tname = l_tab changing c_table = mr_text_table ).
assign mr_text_table->* to <f_tab>.
select * from (l_tab) into table <f_tab> order by primary key.
endmethod. "read_text_table
method update_texts.
data: l_text_field type fieldname,
l_replace type string,
lv_clause type string,
l_tab type tabname.
field-symbols: <f_tab> type any table,
<text_tab> type any table.
field-symbols: <str> type any,
<to> type any,
<check> type any,
<text_str> type any,
<dummy> type any,
<from> type any.
"text fields
lcl_ddic=>get_text_table( exporting i_tname = m_tabname importing e_tab = l_tab ).
check l_tab is not initial.
assign mr_table->* to <f_tab>.
assign mr_text_table->* to <text_tab>.
l_replace = l_tab && '_'.
loop at <f_tab> assigning <str>.
data: ls_comp type abap_componentdescr.
loop at mt_text_components into ls_comp.
l_text_field = ls_comp-name.
replace l_replace in l_text_field with ''.
assign component ls_comp-name of structure <str> to <to>.
assign component m_checkfield of structure <str> to <check>.
check sy-subrc = 0.
lv_clause = |{ m_checkfield } = '{ <check> }'|.
loop at <text_tab> assigning <text_str> where (lv_clause).
exit.
endloop.
if sy-subrc = 0.
assign component 'SPRSL' of structure <text_str> to <dummy>.
if sy-subrc = 0.
lv_clause = |{ lv_clause } AND SPRSL = '{ m_lang }'|.
endif.
assign component 'SPRAS' of structure <text_str> to <dummy>.
if sy-subrc = 0.
lv_clause = |{ lv_clause } AND SPRAS = '{ m_lang }'|.
endif.
else.
continue.
endif.