-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path1.Dynamic SALV Console
2576 lines (1908 loc) · 96.1 KB
/
1.Dynamic SALV Console
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
************************************************************************
* Program name: Z_SALV_ALV
* Description : Dynamic SALV Console
*
* Created by: George Drakos
*
************************************************************************
REPORT z_salv_alv NO STANDARD PAGE HEADING LINE-COUNT 255.
*&---------------------------------------------------------------------*
*& DICTIONARY TABLES-TYPE POOLS
*&---------------------------------------------------------------------*
TYPE-POOLS:icon,slis,cntb.
TABLES sscrfields.
*&---------------------------------------------------------------------*
*& INTEFACES/CLASSES
*&---------------------------------------------------------------------*
INTERFACE: lif_data DEFERRED,
lif_output DEFERRED.
CLASS: lcl_main_salv DEFINITION DEFERRED,
lcl_utilities DEFINITION DEFERRED,
lcl_salv_edit DEFINITION DEFERRED,
lcl_sel_screen DEFINITION DEFERRED,
lcx_exception DEFINITION DEFERRED.
*&---------------------------------------------------------------------*
*& GLOBAL CONSTANTS
*&---------------------------------------------------------------------*
CONSTANTS gc_report_heading TYPE syst-title VALUE 'Dynamic SALV Report'.
*&---------------------------------------------------------------------*
*& GLOBAL DATA DECLARATION
*&---------------------------------------------------------------------*
FIELD-SYMBOLS <fs_table> TYPE INDEX TABLE.
*&----------------------------------------------------------------------*
*& CLASS LCX_EXCEPTION DEFINITION
*&----------------------------------------------------------------------*
CLASS lcx_exception DEFINITION INHERITING FROM cx_static_check FINAL CREATE PUBLIC.
PUBLIC SECTION.
METHODS:
constructor IMPORTING im_text TYPE bapiret2-message OPTIONAL
im_textid TYPE texid OPTIONAL
im_previous TYPE REF TO cx_root OPTIONAL,
get_text REDEFINITION,
get_longtext REDEFINITION.
PRIVATE SECTION.
DATA:
mv_message TYPE bapiret2-message.
ENDCLASS.
*----------------------------------------------------------------------*
* INTEFACE LIF_DATA
*----------------------------------------------------------------------*
INTERFACE lif_data.
TYPES:
BEGIN OF ENUM en_alv_version,
gui,
fiori,
END OF ENUM en_alv_version,
BEGIN OF ENUM en_alv_container,
standard,
bottom,
splitter,
dialog,
context,
END OF ENUM en_alv_container,
BEGIN OF ENUM en_data_source,
excel,
database,
END OF ENUM en_data_source,
BEGIN OF ty_popup_dimensions,
column_start TYPE i,
column_end TYPE i,
line_start TYPE i,
line_end TYPE i,
END OF ty_popup_dimensions.
METHODS:
get_data IMPORTING im_data_source TYPE en_data_source
im_table TYPE tabname OPTIONAL
im_filepath TYPE file_table-filename OPTIONAL
im_sheet_name TYPE char20 OPTIONAL
im_number_of_lines TYPE syst_tabix DEFAULT 100
im_field TYPE char5 OPTIONAL
im_comp TYPE ddoption OPTIONAL
im_val TYPE string OPTIONAL
im_checkbox_column TYPE abap_bool DEFAULT abap_true
im_icon_column TYPE abap_bool DEFAULT abap_true
im_head TYPE abap_bool DEFAULT abap_false
RETURNING VALUE(re_main_salv_instance) TYPE REF TO lif_data
RAISING lcx_exception,
process_data RETURNING VALUE(re_main_salv_instance) TYPE REF TO lif_output
RAISING lcx_exception.
ENDINTERFACE.
*----------------------------------------------------------------------*
* INTEFACE LIF_OUTPUT
*----------------------------------------------------------------------*
INTERFACE lif_output.
METHODS:
display_data RAISING lcx_exception.
ENDINTERFACE.
*----------------------------------------------------------------------*
* CLASS LCL_SEL_SCREEN
*----------------------------------------------------------------------*
CLASS lcl_sel_screen DEFINITION CREATE PRIVATE FINAL.
PUBLIC SECTION.
CLASS-METHODS:
get_instance RETURNING VALUE(re_instance) TYPE REF TO lcl_sel_screen.
METHODS:
screen_initialization RAISING lcx_exception,
screen_pbo RAISING lcx_exception,
color_f4 IMPORTING im_fieldname TYPE help_info-dynprofld
RAISING lcx_exception,
fields_f4 IMPORTING im_fieldname TYPE help_info-dynprofld
RAISING lcx_exception,
screen_pai IMPORTING im_user_command TYPE syst-ucomm
RAISING lcx_exception.
PRIVATE SECTION.
TYPES:BEGIN OF ty_color,
color TYPE lvc_col,
color_descr TYPE as4text,
END OF ty_color,
tt_color TYPE STANDARD TABLE OF ty_color WITH EMPTY KEY.
CLASS-DATA lo_instance TYPE REF TO lcl_sel_screen.
DATA t_color TYPE tt_color.
ENDCLASS.
*----------------------------------------------------------------------*
* CLASS LCL_MAIN_SALV
*----------------------------------------------------------------------*
CLASS lcl_main_salv DEFINITION CREATE PUBLIC FINAL FRIENDS lcl_utilities lcl_salv_edit.
PUBLIC SECTION.
INTERFACES:
if_alv_rm_grid_friend,
lif_output,
lif_data.
ALIASES display_data FOR lif_output~display_data.
ALIASES get_data FOR lif_data~get_data.
ALIASES process_data FOR lif_data~process_data.
METHODS:
constructor IMPORTING im_version TYPE lif_data~en_alv_version
im_popup TYPE abap_bool OPTIONAL
im_container TYPE lif_data~en_alv_container OPTIONAL
im_layout TYPE disvariant-variant OPTIONAL
im_status TYPE rsmpe-status OPTIONAL
im_technical_names TYPE flag OPTIONAL
im_hotspot_field TYPE lvc_fname OPTIONAL
im_hotspot_color TYPE lvc_col OPTIONAL
im_line_color TYPE lvc_col OPTIONAL
im_handle_gui_grid_events TYPE flag DEFAULT abap_false
im_popup_dimensions TYPE lif_data~ty_popup_dimensions OPTIONAL.
PROTECTED SECTION.
CONSTANTS: lc_checkbox TYPE char30 VALUE 'CHECK',
lc_icon_column TYPE char30 VALUE 'ICON',
lc_cell_style TYPE char30 VALUE 'CELL_STYLE',
lc_color_column TYPE char30 VALUE 'LVC_COLOR'.
PRIVATE SECTION.
TYPES:BEGIN OF t_empty_column,
column_name TYPE lvc_fname,
END OF t_empty_column.
DATA: lr_table TYPE REF TO data,
lv_layout TYPE disvariant-variant,
lv_technical_names TYPE flag,
lv_hotspot_field TYPE lvc_fname,
lv_hotspot_color TYPE lvc_col,
lv_line_color TYPE lvc_col,
lv_status TYPE rsmpe-status,
lv_version TYPE lif_data~en_alv_version,
lv_handle_gui_grid_events TYPE flag,
lv_data_source TYPE lif_data~en_data_source,
lv_container TYPE lif_data~en_alv_container,
ls_popup_dimensions TYPE lif_data~ty_popup_dimensions,
lv_popup TYPE abap_bool,
lt_filter_selopt TYPE salv_t_selopt_ref,
lo_salv_alv TYPE REF TO cl_salv_table,
handler_added TYPE abap_bool VALUE abap_false,
lt_empty_columns TYPE STANDARD TABLE OF t_empty_column WITH DEFAULT KEY,
lv_show_hide TYPE abap_bool VALUE abap_false,
lv_editable TYPE abap_bool VALUE abap_false.
METHODS:
create_alv RAISING lcx_exception,
get_docking_container RETURNING VALUE(re_container) TYPE REF TO cl_gui_docking_container,
get_splitter_container RETURNING VALUE(re_container) TYPE REF TO cl_gui_container,
get_dialog_container RETURNING VALUE(re_container) TYPE REF TO cl_gui_dialogbox_container,
get_context_menu_container RETURNING VALUE(re_container) TYPE REF TO cl_gui_container,
field_catalog RAISING lcx_exception,
column_properties RAISING lcx_exception,
display_settings_header RAISING lcx_exception,
header_creation RAISING lcx_exception,
header_creation_fiori RAISING lcx_exception,
footer_creation RAISING lcx_exception,
toolbar_status RAISING lcx_exception,
handle_gui_grid_events RAISING lcx_exception,
event_handling RAISING lcx_exception,
display_alv RAISING lcx_exception,
return_salv_instance RETURNING VALUE(re_salv) TYPE REF TO cl_salv_table,
show_hide_empty_columns,
display_documentation,
display_details_of_selection,
get_text_label_of_rollname IMPORTING im_rollname TYPE rollname
RETURNING VALUE(re_text_label) TYPE scrtext_l,
set_hotspot IMPORTING im_field TYPE lvc_fname
im_alv TYPE REF TO cl_salv_table
RAISING lcx_exception.
"SALV EVENTS
METHODS:
handle_double_click FOR EVENT double_click OF cl_salv_events_table IMPORTING row column,
handle_hotspot FOR EVENT link_click OF cl_salv_events_table IMPORTING row column,
on_user_command FOR EVENT added_function OF cl_salv_events_table IMPORTING e_salv_function,
on_end_of_page FOR EVENT end_of_page OF cl_salv_events_table IMPORTING r_end_of_page page,
on_top_of_page FOR EVENT top_of_page OF cl_salv_events_table IMPORTING r_top_of_page page,
on_after_salv_function FOR EVENT after_salv_function OF cl_salv_events IMPORTING e_salv_function.
"GUI GRID EVENTS
METHODS:
on_function_selected FOR EVENT function_selected OF cl_gui_toolbar IMPORTING fcode sender,
event_after_refresh FOR EVENT after_refresh OF cl_gui_alv_grid IMPORTING sender,
on_toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object e_interactive sender.
ENDCLASS.
*----------------------------------------------------------------------*
* CLASS lcl_utilities DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_utilities DEFINITION CREATE PUBLIC FRIENDS lcl_main_salv.
PUBLIC SECTION.
CLASS-METHODS:
dynamic_where_clause IMPORTING im_field TYPE char5
im_comp TYPE ddoption DEFAULT if_fsbp_const_range=>option_equal
im_val TYPE string
im_table_name TYPE tabname
RETURNING VALUE(re_select_clause) TYPE hrtb_cond,
open_dialog_excel RETURNING VALUE(re_filepath) TYPE file_table-filename,
check_field_exists_in_table IMPORTING im_field TYPE char5
im_table TYPE tabname30
RETURNING VALUE(re_exists) TYPE abap_bool,
f4_salv CHANGING cv_layout TYPE disvariant-variant,
get_structured_table_from_gen IMPORTING im_table TYPE ANY TABLE
im_map_by_structure TYPE abap_bool OPTIONAL
im_structure_line TYPE i DEFAULT 1
im_start_line TYPE i DEFAULT 2
EXPORTING ex_table TYPE ANY TABLE,
upload_excel IMPORTING im_filepath TYPE file_table-filename
im_sheet_name TYPE char20 OPTIONAL
im_sheet_number TYPE i OPTIONAL
EXPORTING ex_table TYPE REF TO data
RAISING lcx_exception.
PROTECTED SECTION.
TYPES:
BEGIN OF ENUM t_alpha_conversion STRUCTURE s_alpha_conversion BASE TYPE char1,
in VALUE 1,
out VALUE 2,
other VALUE IS INITIAL,
END OF ENUM t_alpha_conversion STRUCTURE s_alpha_conversion.
CLASS-METHODS:
alpha_conversion IMPORTING VALUE(iv_input) TYPE any
im_alpha TYPE lcl_utilities=>t_alpha_conversion DEFAULT s_alpha_conversion-in
EXPORTING VALUE(ev_output) TYPE any,
date_external_to_internal IMPORTING im_date TYPE string
RETURNING VALUE(re_date_internal) TYPE tumls_date.
ENDCLASS.
*----------------------------------------------------------------------*
* CLASS lcl_salv_edit DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_salv_edit DEFINITION INHERITING FROM cl_salv_controller CREATE PRIVATE FINAL.
PUBLIC SECTION.
CLASS-METHODS:
set_editable IMPORTING VALUE(i_fieldname) TYPE csequence OPTIONAL
i_salv_table TYPE REF TO cl_salv_table
VALUE(i_editable) TYPE abap_bool DEFAULT abap_true
VALUE(i_refresh) TYPE abap_bool DEFAULT abap_true.
PRIVATE SECTION.
CLASS-METHODS: get_control IMPORTING i_salv TYPE REF TO cl_salv_model_base
RETURNING VALUE(r_control) TYPE REF TO object.
ENDCLASS."lcl_salv_edit DEFINITION
*&---------------------------------------------------------------------*
*& SELECTION SCREEN DESIGN
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b0 WITH FRAME TITLE title0.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_db FOR FIELD db.
PARAMETERS: db RADIOBUTTON GROUP rb0 DEFAULT 'X' USER-COMMAND dummy.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_file FOR FIELD file.
PARAMETERS:file RADIOBUTTON GROUP rb0.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b0.
SELECTION-SCREEN BEGIN OF BLOCK b05 WITH FRAME TITLE title05.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_excel FOR FIELD p_excel MODIF ID id3.
PARAMETERS: p_excel TYPE file_table-filename MODIF ID id3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_sheet FOR FIELD p_sheet MODIF ID id3.
PARAMETERS: p_sheet TYPE char20 MODIF ID id3 LOWER CASE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_head FOR FIELD p_head MODIF ID id3.
PARAMETERS: p_head AS CHECKBOX DEFAULT '' MODIF ID id3.
SELECTION-SCREEN COMMENT 27(42) t_hdesc MODIF ID id3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b05.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE title1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_table FOR FIELD p_table MODIF ID id4.
PARAMETERS: p_table TYPE tabname OBLIGATORY DEFAULT 'BSEG' MATCHCODE OBJECT dd_dbtb_16 MODIF ID id4.
SELECTION-SCREEN COMMENT 57(55) t_descr MODIF ID id4.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_editf TYPE lvc_fname NO-DISPLAY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_hotsp FOR FIELD p_hotsp MODIF ID id4.
PARAMETERS: p_hotsp TYPE lvc_fname MODIF ID id4.
SELECTION-SCREEN COMMENT 57(55) h_descr MODIF ID id4.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_colh FOR FIELD p_colh MODIF ID id4.
PARAMETERS: p_colh TYPE lvc_col DEFAULT 6 MODIF ID id4.
SELECTION-SCREEN COMMENT 38(50) t_desch MODIF ID id4.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_coll FOR FIELD p_coll.
PARAMETERS: p_coll TYPE lvc_col DEFAULT space.
SELECTION-SCREEN COMMENT 38(50) t_descl.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_layout FOR FIELD p_layout MODIF ID id4.
PARAMETERS: p_layout TYPE disvariant-variant VISIBLE LENGTH 11 MODIF ID id4.
SELECTION-SCREEN COMMENT 38(50) t_ldescr MODIF ID id4.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_hits FOR FIELD p_hits MODIF ID id4.
PARAMETERS: p_hits TYPE syst_tabix DEFAULT 10 MODIF ID id4.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_names FOR FIELD p_names MODIF ID id4.
PARAMETERS: p_names AS CHECKBOX DEFAULT space MODIF ID id4.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_check FOR FIELD p_check.
PARAMETERS: p_check AS CHECKBOX DEFAULT space.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_icon FOR FIELD p_icon.
PARAMETERS: p_icon AS CHECKBOX DEFAULT space.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_r1 FOR FIELD r1.
PARAMETERS: r1 RADIOBUTTON GROUP rb1 DEFAULT 'X' USER-COMMAND dummy.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_r2 FOR FIELD r2.
PARAMETERS: r2 RADIOBUTTON GROUP rb1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE title4.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_fiel TYPE char5 MODIF ID id4,
p_comp TYPE ddoption DEFAULT if_fsbp_const_range=>option_equal MODIF ID id4,
p_val TYPE string MODIF ID id4.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b4.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE title2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_stand FOR FIELD p_stand MODIF ID id1.
PARAMETERS: p_stand RADIOBUTTON GROUP rb2 DEFAULT 'X' MODIF ID id1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_doc FOR FIELD p_doc MODIF ID id1.
PARAMETERS: p_doc RADIOBUTTON GROUP rb2 MODIF ID id1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_split FOR FIELD p_split MODIF ID id1.
PARAMETERS: p_split RADIOBUTTON GROUP rb2 MODIF ID id1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_dial FOR FIELD p_dial MODIF ID id1.
PARAMETERS: p_dial RADIOBUTTON GROUP rb2 MODIF ID id1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_cont FOR FIELD p_cont MODIF ID id1.
PARAMETERS: p_cont RADIOBUTTON GROUP rb2 MODIF ID id1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_event FOR FIELD p_event MODIF ID id1.
PARAMETERS: p_event AS CHECKBOX MODIF ID id1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE title3.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_popup FOR FIELD p_popup MODIF ID id2.
PARAMETERS: p_popup AS CHECKBOX DEFAULT space MODIF ID id2 USER-COMMAND dummy.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_col_s FOR FIELD p_col_s MODIF ID id5.
PARAMETERS: p_col_s TYPE i DEFAULT 1 MODIF ID id5.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_col_e FOR FIELD p_col_e MODIF ID id5.
PARAMETERS: p_col_e TYPE i DEFAULT 140 MODIF ID id5.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_lin_s FOR FIELD p_lin_s MODIF ID id5.
PARAMETERS: p_lin_s TYPE i DEFAULT 1 MODIF ID id5.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_lin_e FOR FIELD p_lin_e MODIF ID id5.
PARAMETERS: p_lin_e TYPE i DEFAULT 30 MODIF ID id5.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(26) t_status FOR FIELD p_status MODIF ID id2.
PARAMETERS: p_status TYPE rsmpe-status MODIF ID id2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b3.
*&---------------------------------------------------------------------*
*& INITIALIZATION OF SELECTION SCREEN ELEMENTS
*&---------------------------------------------------------------------*
INITIALIZATION.
lcl_sel_screen=>get_instance( )->screen_initialization( ).
*&---------------------------------------------------------------------*
*& AT SELECTION SCREEN MODIFICATION (PBO)
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
lcl_sel_screen=>get_instance( )->screen_pbo( ).
*&---------------------------------------------------------------------*
*& AT SELECTION SCREEN ON VALUE REQUESTS (F4)
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
lcl_utilities=>f4_salv( CHANGING cv_layout = p_layout ).
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_hotsp.
lcl_sel_screen=>get_instance( )->fields_f4( 'P_HOTSP' ).
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fiel.
lcl_sel_screen=>get_instance( )->fields_f4( 'P_FIEL' ).
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_coll.
lcl_sel_screen=>get_instance( )->color_f4( 'P_COLL' ).
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_colh.
lcl_sel_screen=>get_instance( )->color_f4( 'P_COLH' ).
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_excel.
p_excel = lcl_utilities=>open_dialog_excel( ).
*&---------------------------------------------------------------------*
*& AT SELECTION SCREEN Actions(PAI)
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN.
lcl_sel_screen=>get_instance( )->screen_pai( sscrfields-ucomm ).
*&---------------------------------------------------------------------*
*& EXECUTABLE CODE
*&---------------------------------------------------------------------*
START-OF-SELECTION.
TRY.
NEW lcl_main_salv( im_version = COND #( WHEN r1 EQ abap_true THEN lcl_main_salv=>lif_data~gui
WHEN r2 EQ abap_true THEN lcl_main_salv=>lif_data~fiori
ELSE lcl_main_salv=>lif_data~fiori )
im_popup = p_popup
im_container = COND #( WHEN p_stand EQ abap_true THEN lcl_main_salv=>lif_data~standard
WHEN p_doc EQ abap_true THEN lcl_main_salv=>lif_data~bottom
WHEN p_split EQ abap_true THEN lcl_main_salv=>lif_data~splitter
WHEN p_dial EQ abap_true THEN lcl_main_salv=>lif_data~dialog
WHEN p_cont EQ abap_true THEN lcl_main_salv=>lif_data~context
ELSE lcl_main_salv=>lif_data~standard )
im_layout = p_layout
im_technical_names = p_names
im_status = p_status
im_hotspot_field = p_hotsp
im_hotspot_color = p_colh
im_line_color = p_coll
im_handle_gui_grid_events = p_event
im_popup_dimensions = VALUE #( column_start = p_col_s
column_end = p_col_e
line_start = p_lin_s
line_end = p_lin_e )
)->get_data( im_data_source = COND #( WHEN db EQ abap_true THEN lcl_main_salv=>lif_data~database
WHEN file EQ abap_true THEN lcl_main_salv=>lif_data~excel
ELSE THROW lcx_exception( im_text = 'Invalid Data Source Selection' ) )
im_filepath = p_excel
im_sheet_name = p_sheet
im_head = p_head
im_table = p_table
im_number_of_lines = p_hits
im_comp = p_comp
im_field = p_fiel
im_val = p_val
im_checkbox_column = p_check
im_icon_column = p_icon
)->process_data(
)->display_data( ).
CATCH lcx_exception INTO DATA(lo_exception).
MESSAGE lo_exception->get_text( ) TYPE cl_cms_common=>con_msg_typ_i DISPLAY LIKE cl_cms_common=>con_msg_typ_e.
ENDTRY.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& END OF EXECUTABLE CODE
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
*CLASS LCL_MAIN_SALV IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_main_salv IMPLEMENTATION.
METHOD constructor.
"SET VALUES TO INSTANCE ATTRIBUTES
me->lv_layout = im_layout.
me->lv_technical_names = im_technical_names.
me->lv_hotspot_field = im_hotspot_field.
me->lv_hotspot_color = im_hotspot_color.
me->lv_line_color = im_line_color.
me->lv_handle_gui_grid_events = im_handle_gui_grid_events.
me->lv_version = im_version.
me->lv_container = im_container.
me->lv_status = im_status.
me->ls_popup_dimensions = im_popup_dimensions.
me->lv_popup = im_popup.
"SET TITLE FOR ALV SCREEN
syst-title = gc_report_heading.
ENDMETHOD.
METHOD get_data.
re_main_salv_instance = me.
IF im_data_source EQ lcl_main_salv=>lif_data~excel AND im_filepath IS NOT INITIAL.
me->lv_data_source = lcl_main_salv=>lif_data~excel.
lcl_utilities=>upload_excel(
EXPORTING
im_filepath = im_filepath
im_sheet_name = im_sheet_name
IMPORTING
ex_table = DATA(lo_data_ref) ).
"Create Dynamic Internal Table with Column Heading
DATA(lt_component) = VALUE cl_abap_structdescr=>component_table(
( name = lc_cell_style type = CAST #( cl_abap_elemdescr=>describe_by_name( 'salv_t_int4_column' ) ) )
( name = lc_color_column type = CAST #( cl_abap_elemdescr=>describe_by_name( 'lvc_t_scol' ) ) ) ).
IF im_icon_column EQ abap_true.
APPEND VALUE abap_componentdescr( name = lc_icon_column type = cl_abap_elemdescr=>get_c( cl_mmim_maa_2=>gc_integer_8 ) ) TO lt_component.
ENDIF.
IF im_checkbox_column EQ abap_true.
APPEND VALUE abap_componentdescr( name = lc_checkbox type = cl_abap_elemdescr=>get_c( cl_mmim_maa_2=>gc_integer_1 ) ) TO lt_component.
ENDIF.
FIELD-SYMBOLS: <fs_tab> TYPE STANDARD TABLE.
ASSIGN lo_data_ref->* TO <fs_tab>.
DO.
ASSIGN COMPONENT syst-index OF STRUCTURE <fs_tab>[ 1 ] TO FIELD-SYMBOL(<fs>).
IF <fs> IS NOT INITIAL AND
syst-subrc IS INITIAL.
IF im_head EQ abap_true.
CONDENSE <fs> NO-GAPS.
APPEND VALUE #( name = |{ <fs> }| type = cl_abap_elemdescr=>get_c( 30 ) ) TO lt_component.
ELSE.
APPEND VALUE #( name = |column_{ syst-index }| type = cl_abap_elemdescr=>get_c( 30 ) ) TO lt_component.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
"Table type
TRY.
DATA(lo_new_table) = cl_abap_tabledescr=>create(
p_line_type = cl_abap_structdescr=>create( lt_component )
p_table_kind = cl_abap_tabledescr=>tablekind_std
p_unique = abap_false ).
CATCH cx_sy_struct_attributes cx_sy_struct_comp_name INTO DATA(lo_exception). "#EC NO_HANDLER
RAISE EXCEPTION TYPE lcx_exception EXPORTING im_text = CONV #( lo_exception->get_text( ) ).
ENDTRY.
"Data to handle the new table type
CREATE DATA me->lr_table TYPE HANDLE lo_new_table.
"New internal table in fieldsymbol
ASSIGN me->lr_table->* TO <fs_table>.
"MAP VALUE TABLE TO STRUCTURED TABLE
lcl_utilities=>get_structured_table_from_gen(
EXPORTING
im_map_by_structure = COND #( WHEN im_head EQ abap_true THEN abap_false
WHEN im_head EQ abap_false THEN abap_true )
im_start_line = COND #( WHEN im_head EQ abap_true THEN 2
WHEN im_head EQ abap_false THEN 1 )
im_table = <fs_tab>
IMPORTING
ex_table = <fs_table> ).
ELSEIF im_data_source EQ lcl_main_salv=>lif_data~database AND im_table IS NOT INITIAL.
me->lv_data_source = lcl_main_salv=>lif_data~database.
"Build Components of Dynamic Table
DATA(lt_tot_comp) = VALUE cl_abap_structdescr=>component_table(
( name = lc_cell_style type = CAST #( cl_abap_elemdescr=>describe_by_name( 'salv_t_int4_column' ) ) )
( name = lc_color_column type = CAST #( cl_abap_elemdescr=>describe_by_name( 'lvc_t_scol' ) ) ) ).
IF im_icon_column EQ abap_true.
APPEND VALUE abap_componentdescr( name = lc_icon_column type = cl_abap_elemdescr=>get_c( cl_mmim_maa_2=>gc_integer_8 ) ) TO lt_tot_comp.
ENDIF.
IF im_checkbox_column EQ abap_true.
APPEND VALUE abap_componentdescr( name = lc_checkbox type = cl_abap_elemdescr=>get_c( cl_mmim_maa_2=>gc_integer_1 ) ) TO lt_tot_comp.
ENDIF.
DATA(lo_struct) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( im_table ) ).
DATA(lt_comp) = lo_struct->get_components( ).
APPEND LINES OF lt_comp TO lt_tot_comp.
DELETE lt_tot_comp WHERE suffix IS NOT INITIAL.
"Table type
TRY.
DATA(lo_new_tab) = cl_abap_tabledescr=>create(
p_line_type = cl_abap_structdescr=>create( lt_tot_comp )
p_table_kind = cl_abap_tabledescr=>tablekind_std
p_unique = abap_false ).
CATCH cx_sy_struct_attributes cx_sy_struct_comp_name INTO DATA(lo_exception2). "#EC NO_HANDLER
RAISE EXCEPTION TYPE lcx_exception EXPORTING im_text = CONV #( lo_exception2->get_text( ) ).
ENDTRY.
"Data to handle the new table type
CREATE DATA me->lr_table TYPE HANDLE lo_new_tab.
"New internal table in fieldsymbol
ASSIGN me->lr_table->* TO <fs_table>.
"Build Dynamic Where Clause
IF ( im_field IS NOT INITIAL ) AND ( im_comp IS NOT INITIAL ) AND ( im_val IS NOT INITIAL ) .
DATA(lt_select_clause) = lcl_utilities=>dynamic_where_clause( im_comp = im_comp
im_field = im_field
im_val = im_val
im_table_name = im_table ).
ENDIF.
IF <fs_table> IS ASSIGNED.
SELECT *
FROM (im_table)
INTO CORRESPONDING FIELDS OF TABLE @<fs_table>
UP TO @im_number_of_lines ROWS
WHERE (lt_select_clause).
IF <fs_table> IS INITIAL.
RAISE EXCEPTION TYPE lcx_exception EXPORTING im_text = | No values Retrieved from Table: { im_table } |.
ENDIF.
ELSE.
RAISE EXCEPTION TYPE lcx_exception EXPORTING im_text = 'Error while Creating Dynamic Table'.
ENDIF.
ELSE.
RAISE EXCEPTION TYPE lcx_exception EXPORTING im_text = 'Missing Parameters for Data Retrieval'.
ENDIF.
ENDMETHOD.
METHOD process_data.
re_main_salv_instance = me.
LOOP AT <fs_table> ASSIGNING FIELD-SYMBOL(<fs_structure>).
ASSIGN COMPONENT lc_icon_column OF STRUCTURE <fs_structure> TO FIELD-SYMBOL(<lv_icon_value>).
ASSIGN COMPONENT lc_color_column OF STRUCTURE <fs_structure> TO FIELD-SYMBOL(<lv_color_value>).
ASSIGN COMPONENT lc_cell_style OF STRUCTURE <fs_structure> TO FIELD-SYMBOL(<lv_cell_style>).
"Color Hotspot Field
IF me->lv_hotspot_field IS NOT INITIAL AND
me->lv_hotspot_color IS NOT INITIAL AND
<lv_color_value> IS ASSIGNED.
<lv_color_value> = VALUE lvc_t_scol( ( fname = lv_hotspot_field
color-col = lv_hotspot_color
color-int = 0
color-inv = 0 ) ).
ENDIF.
"Color of Lines
IF me->lv_line_color IS NOT INITIAL AND
<lv_color_value> IS ASSIGNED.
<lv_color_value> = VALUE lvc_t_scol( ( color-col = lv_line_color
color-int = 0
color-inv = 0 ) ).
ENDIF.
"Set Cell Style
IF <lv_cell_style> IS ASSIGNED.
<lv_cell_style> = VALUE salv_t_int4_column( ( columnname = 'COLUMN_NAME'
value = if_salv_c_cell_type=>button ) ).
ENDIF.
"Icons
IF <lv_icon_value> IS ASSIGNED.
<lv_icon_value> = SWITCH #( syst-tabix MOD 4
WHEN 1 THEN icon_green_light
WHEN 2 THEN icon_cancel
WHEN 3 THEN icon_locked
ELSE icon_address ).
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD display_data.
me->create_alv( ).
me->field_catalog( ).
me->column_properties( ).
me->display_settings_header( ).
me->header_creation( ).
me->footer_creation( ).
me->toolbar_status( ).
me->handle_gui_grid_events( ).
me->event_handling( ).
me->display_alv( ).
ENDMETHOD.
METHOD create_alv.
CASE me->lv_version.
WHEN lcl_main_salv=>lif_data~gui.
TRY.
cl_salv_table=>factory( EXPORTING r_container = SWITCH #( me->lv_container
WHEN lcl_main_salv=>lif_data~bottom THEN me->get_docking_container( )
WHEN lcl_main_salv=>lif_data~standard THEN cl_gui_container=>default_screen
WHEN lcl_main_salv=>lif_data~splitter THEN me->get_splitter_container( )
WHEN lcl_main_salv=>lif_data~dialog THEN me->get_dialog_container( )
WHEN lcl_main_salv=>lif_data~context THEN me->get_context_menu_container( ) )
list_display = if_salv_c_bool_sap=>false
IMPORTING r_salv_table = me->lo_salv_alv
CHANGING t_table = <fs_table> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
WHEN lcl_main_salv=>lif_data~fiori.
TRY.
cl_salv_table=>factory( EXPORTING list_display = if_salv_c_bool_sap=>false
IMPORTING r_salv_table = me->lo_salv_alv
CHANGING t_table = <fs_table> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
IF me->lv_popup EQ abap_true.
me->lo_salv_alv->set_screen_popup( start_column = me->ls_popup_dimensions-column_start
end_column = me->ls_popup_dimensions-column_end
start_line = me->ls_popup_dimensions-line_start
end_line = me->ls_popup_dimensions-line_end ).
ENDIF.
ENDCASE.
IF me->lo_salv_alv IS NOT BOUND.
RAISE EXCEPTION TYPE lcx_exception EXPORTING im_text = 'Error while creating ALV Reference'.
ENDIF.
ENDMETHOD.
METHOD get_docking_container.
re_container = NEW #( no_autodef_progid_dynnr = abap_true
side = cl_gui_docking_container=>dock_at_bottom
ratio = 90 ).
ENDMETHOD.
METHOD get_splitter_container.
DATA(o_splitter_container) = NEW cl_gui_splitter_container( parent = cl_gui_container=>default_screen
no_autodef_progid_dynnr = abap_true
rows = 1
columns = 2 ).
re_container = o_splitter_container->get_container( row = 1 column = 1 ).
ENDMETHOD.
METHOD get_dialog_container.
re_container = NEW #( no_autodef_progid_dynnr = abap_true
caption = 'ALV in Dialog Box'
top = 20
left = 20
width = 1280
height = 400 ).
ENDMETHOD.
METHOD get_context_menu_container.
"CREATE SPLITTER
DATA(o_splitter) = NEW cl_gui_splitter_container( parent = cl_gui_container=>default_screen
no_autodef_progid_dynnr = abap_true
rows = 2
columns = 1 ).
"ABSOLUTE ROW HEIGHT
o_splitter->set_row_mode( mode = cl_gui_splitter_container=>mode_absolute ).
"ABSOLUTE HEIGHT 24 PIXELS FOR SPLITTER ABOVE
o_splitter->set_row_height( id = 1 height = 24 ).
"Splitter for top container fixed and hidden
o_splitter->set_row_sash( id = 1
type = cl_gui_splitter_container=>type_movable
value = cl_gui_splitter_container=>false ).
o_splitter->set_row_sash( id = 1
type = cl_gui_splitter_container=>type_sashvisible
value = cl_gui_splitter_container=>false ).
"Create Top and Bottom Custom Container
DATA(o_container_top) = o_splitter->get_container( row = 1 column = 1 ).
re_container = o_splitter->get_container( row = 2 column = 1 ).
"Horizontal Toolbar
DATA(o_tool) = NEW cl_gui_toolbar( parent = o_container_top
display_mode = cl_gui_toolbar=>m_mode_horizontal ).
"Register of Event Types.Must be registered Separately
TYPES: ty_it_events TYPE STANDARD TABLE OF cntl_simple_event WITH DEFAULT KEY.
DATA(it_events) = VALUE ty_it_events( ( eventid = cl_gui_toolbar=>m_id_function_selected
appl_event = abap_true ) ).
o_tool->set_registered_events( events = it_events ).
"Add toolbar buttons. Button types are defined in type group CNTB
o_tool->add_button( fcode = 'BTN_MENU'
icon = icon_activate
butn_type = cntb_btype_menu
text = 'Menu'
quickinfo = 'Menu'
is_checked = abap_false
is_disabled = abap_false ).
DATA(o_menu) = NEW cl_ctmenu( ).
o_menu->add_function( fcode = 'F1'
checked = abap_false
text = 'Function1' ).
o_menu->add_function( fcode = 'F2'
checked = abap_false
text = 'Function2' ).