-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathzsos_overview.prog.abap
1565 lines (1336 loc) · 52.7 KB
/
zsos_overview.prog.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 ZSOS_OVERVIEW
*& Show EWA and SOS rating overview
*&---------------------------------------------------------------------*
*&
*&
*& 24.08.2021 Initial version
*& 25.08.2021 Show SOS Check ID
*& 30.08.2021 Show count
*& 20.01.2022 Option to choose ALV layout
*& Default selection for change datum
*& Turn count field into integer for easy filtering (but no differentiation between empty and zero anymore)
*& Value help for rating
*& 27.01.2022 Support for icon @0S@ 'information'
*& 01.02.2022 Correction to show the lastest SOS per system
*& 27.07.2022 Show results from EWA as well
*& 19.05.2023 Show user count for SOS, too
*& 30.05.2023 Optimized selection for user count entries
*& 04.09.2023 Process not only GSS SOS but normal SOS as well
*&---------------------------------------------------------------------*
REPORT zsos_overview
MESSAGE-ID dsvas.
CONSTANTS: c_program_version(30) TYPE c VALUE '04.09.2023'.
*&---------------------------------------------------------------------*
* SALV types and data
TYPES:
BEGIN OF ts_outtab,
instno TYPE dsvasdinstno,
dbid TYPE dsvasddbid,
sessno TYPE dsvasdsessino,
bundle_id TYPE dsvassessadmin-bundle_id, " Bundle id
sessitype TYPE dsvasdsessitype, " Session type
change_date TYPE dsvasdchangedate,
creation_date TYPE dsvasdcreatdate,
row TYPE i,
main_chapter TYPE string,
chapter TYPE string,
check TYPE string,
alert_id TYPE string, " only used for EWA
sos_check_id TYPE string, " only used for SOS
rating TYPE string,
rating_text TYPE string,
count TYPE i, " only used for SOS
check_group TYPE dsvasdcheckgrp,
check_id TYPE dsvasdcheckid,
con TYPE dsvasdcontext,
ins TYPE dsvasdcontextinstance,
END OF ts_outtab,
tt_outtab TYPE TABLE OF ts_outtab.
DATA:
ls_outtab TYPE ts_outtab,
lt_outtab TYPE tt_outtab.
*&---------------------------------------------------------------------*
* Selection screen
SELECTION-SCREEN BEGIN OF BLOCK type WITH FRAME TITLE s_type.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS s_ewa RADIOBUTTON GROUP type USER-COMMAND type. "user command required to trigger OUTPUT event
SELECTION-SCREEN COMMENT 3(40) ss_ewa FOR FIELD s_ewa.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS s_sos RADIOBUTTON GROUP type DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(40) ss_sos FOR FIELD s_sos.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK type.
SELECTION-SCREEN BEGIN OF BLOCK sess WITH FRAME TITLE s_sess.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_inst FOR FIELD instno.
SELECT-OPTIONS instno FOR ls_outtab-instno.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_dbid FOR FIELD dbid.
SELECT-OPTIONS dbid FOR ls_outtab-dbid.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_udate FOR FIELD chgdate.
SELECT-OPTIONS chgdate FOR ls_outtab-change_date.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_cdate FOR FIELD credate.
SELECT-OPTIONS credate FOR ls_outtab-creation_date.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_sess FOR FIELD sessno.
SELECT-OPTIONS sessno FOR ls_outtab-sessno.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK sess.
SELECTION-SCREEN BEGIN OF BLOCK chap WITH FRAME TITLE s_chap.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_main FOR FIELD main.
DATA s_main_chapter(40).
SELECT-OPTIONS main FOR s_main_chapter LOWER CASE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_chap FOR FIELD chapter.
DATA s_chapter(40).
SELECT-OPTIONS chapter FOR s_chapter LOWER CASE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_chk FOR FIELD chk.
DATA s_check(40).
SELECT-OPTIONS chk FOR s_check LOWER CASE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_ewaid FOR FIELD ewa_id MODIF ID ewa.
DATA s_alert_id TYPE i.
SELECT-OPTIONS ewa_id FOR s_alert_id MODIF ID ewa.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_sosid FOR FIELD sos_id MODIF ID sos.
DATA s_sos_check_id(20).
SELECT-OPTIONS sos_id FOR s_sos_check_id MODIF ID sos.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_chkgp FOR FIELD chkgrp.
SELECT-OPTIONS chkgrp FOR ls_outtab-check_group.
SELECTION-SCREEN END OF LINE.
"SELECTION-SCREEN BEGIN OF LINE.
"SELECTION-SCREEN COMMENT 1(28) ss_chkid FOR FIELD chkid.
"SELECT-OPTIONS chkid FOR ls_outtab-check_id.
"SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) ss_rat FOR FIELD rating.
DATA s_rating_text(40).
SELECT-OPTIONS rating FOR s_rating_text LOWER CASE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK chap.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_new AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(40) ss_new FOR FIELD p_new.
SELECTION-SCREEN END OF LINE.
* Layout of ALV output
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) ps_lout FOR FIELD p_layout.
PARAMETERS p_layout TYPE disvariant-variant.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN COMMENT 1(60) ss_vers.
*&---------------------------------------------------------------------*
* Constants to distinguish between EWA and SOS
DATA:
c_bundle_id TYPE dsvassessadmin-bundle_id, " Bundle id
c_relid TYPE dsvasresultsgen-relid, " Check tables
c_sessitype TYPE dsvasdsessitype, " Session type
c_grp TYPE dsvasdcheckgrp, " Rating overview
c_id TYPE dsvasdcheckid, " Check Overview
c_ses_gr_typ TYPE dsvasdsessgrptype, " Authorization object D_SVAS_SES
c_pkg_id_typ TYPE dsvasdpkgidtype, " Authorization object D_SVAS_SES
c_days TYPE i. " Days for value help on sessions
INITIALIZATION.
s_type = 'Session type'(010).
ss_ewa = 'EarlyWatch Alert (EWA)'(011).
ss_sos = 'Security Optimization Service (SOS)'(012).
s_sess = 'Select session'(001).
ss_inst = 'Installation number'(002).
ss_dbid = 'System ID'(m09).
ss_udate = 'Change date'(003).
ss_cdate = 'Create date'(004).
ss_sess = 'Session number'(m10).
s_chap = 'Filter'(005).
ss_main = 'Main chapter'(m01).
ss_chap = 'Chapter'(m02).
ss_chk = 'Check'(m03).
ss_ewaid = 'EWA Alert ID'(m15).
ss_sosid = 'SOS Check ID'(m12).
ss_chkgp = 'Check group'(006).
"ss_chkid = 'Check ID'(007).
ss_rat = 'Rating'(m04).
ps_lout = 'Layout'(008).
ss_new = 'Newest result per system only'(009).
CONCATENATE 'Program version:'(VER) c_program_version INTO ss_vers
SEPARATED BY space.
* Default values
GET PARAMETER ID 'DSVAS_SESSNO' FIELD sessno.
*&---------------------------------------------------------------------*
TABLES sscrfields.
AT SELECTION-SCREEN.
IF sscrfields-ucomm EQ 'TYPE'. "radiobutton was changed
CLEAR: sessno, sessno[].
ENDIF.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'EWA'.
IF s_ewa = 'X'.
screen-active = '1'.
ELSE.
screen-active = '0'.
ENDIF.
MODIFY SCREEN.
ELSEIF screen-group1 = 'SOS'.
IF s_sos = 'X'.
screen-active = '1'.
ELSE.
screen-active = '0'.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
IF s_ewa = 'X'.
c_bundle_id = 'EW_ALERT'. " Bundle id
c_sessitype = 'EA'. " Session type
c_relid = 'CT'. " Check tables
c_grp = 'EA_HEAD'. " Rating overview
c_id = '00003'. " 00003 Check Overview, 00018 Alert Overview and Service Summary
c_ses_gr_typ = 'Earlywatch/Alert'. " Authorization check
c_pkg_id_typ = 'EW_ALERT/EA'. " Authorization check
c_days = 30. " Get EWA sessions which are not older than one month
ELSEIF s_sos = 'X'.
c_bundle_id = 'GSS_SEC'. " Bundle id GSS_SEC and SEC
c_sessitype = 'GS'. " Session type GS and SC
c_relid = 'CT'. " Check tables
c_grp = 'SC_FINISH'. " Rating overview
c_id = '00013'. " Rating overview, get it either from check 00013 or from check 00011
c_ses_gr_typ = 'GSS Security Service/Session GS'. " Authorization check
c_pkg_id_typ = 'GSS_SEC/GS'. " Authorization check
c_days = 365. " Get SOS sessions which are not older than one year
ENDIF.
CLEAR: chgdate, chgdate[].
chgdate-option = 'GE'.
chgdate-sign = 'I'.
chgdate-low = sy-datum - c_days. " Omit old sessions
APPEND chgdate.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST FOR sessno
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sessno-low.
PERFORM f4_sessno USING 'SESSNO-LOW'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sessno-high.
PERFORM f4_sessno USING 'SESSNO-HIGH'.
FORM f4_sessno
USING
l_dynprofield TYPE help_info-dynprofld.
DATA:
retfield TYPE dfies-fieldname,
"dynpro_values TYPE TABLE OF dynpread,
"field_value LIKE LINE OF dynpro_values,
"field_tab TYPE TABLE OF dfies WITH HEADER LINE,
field_mapping TYPE STANDARD TABLE OF dselc,
BEGIN OF value_tab_EWA OCCURS 0,
sessno TYPE dsvassessadmin-sessno,
"bundle_id TYPE dsvassessadmin-bundle_id,
"bundle_versnr TYPE dsvassessadmin-bundle_versnr,
"sessitype TYPE dsvassessadmin-sessitype,
dbid TYPE dsvassessadmin-dbid,
change_user TYPE dsvassessadmin-change_user,
change_date TYPE dsvassessadmin-change_date,
description TYPE dsvassessadmin-description,
END OF value_tab_EWA,
BEGIN OF value_tab_SOS OCCURS 0,
sessno TYPE dsvassessadmin-sessno,
bundle_id TYPE dsvassessadmin-bundle_id,
"bundle_versnr TYPE dsvassessadmin-bundle_versnr,
sessitype TYPE dsvassessadmin-sessitype,
dbid TYPE dsvassessadmin-dbid,
change_user TYPE dsvassessadmin-change_user,
change_date TYPE dsvassessadmin-change_date,
description TYPE dsvassessadmin-description,
END OF value_tab_SOS.
DATA(min_change_date) = sy-datum - c_days.
IF s_ewa = 'X'.
SELECT
h~sessno,
"a~bundle_id,
"a~bundle_versnr,
"h~sessitype,
h~change_user,
h~change_date,
a~dbid,
a~description
FROM dsvassessionhead AS h
JOIN dsvassessadmin AS a
ON a~sessno = h~sessno
JOIN dsvasresultsgen AS r " Only sessions having results
ON r~relid = @c_relid " Check tables
AND r~sessitype = h~sessitype " Session type
AND r~sessno = h~sessno
AND r~grp = @c_grp " Rating overview
AND r~id = @c_id " Check Overview
AND r~srtf2 = 0 " first entry
INTO CORRESPONDING FIELDS OF @value_tab_EWA
WHERE ( a~bundle_id = @c_bundle_id AND h~sessitype = @c_sessitype )
AND a~dbid IN @dbid
AND a~change_date >= @min_change_date
ORDER BY a~dbid ASCENDING, a~change_date DESCENDING.
APPEND value_tab_EWA.
"SORT value_tab_EWA BY dbid ASCENDING change_date DESCENDING.
ENDSELECT.
retfield = l_dynprofield.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'SESSNO' "retfield "(I do not know why this works better)
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = l_dynprofield
value_org = 'S'
TABLES
* field_tab = field_tab
value_tab = value_tab_EWA
"dynpfld_mapping = field_mapping
EXCEPTIONS
parameter_error = 1
no_values_found = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ELSEIF s_sos = 'X'.
SELECT
h~sessno,
a~bundle_id,
"a~bundle_versnr,
h~sessitype,
a~dbid,
h~change_user,
h~change_date,
a~description
FROM dsvassessionhead AS h
JOIN dsvassessadmin AS a
ON a~sessno = h~sessno
JOIN dsvasresultsgen AS r " Only sessions having results
ON r~relid = @c_relid " Check tables
AND r~sessitype = h~sessitype " Session type
AND r~sessno = h~sessno
AND r~grp = @c_grp " Rating overview
AND r~id = @c_id " Check Overview
AND r~srtf2 = 0 " first entry
INTO CORRESPONDING FIELDS OF @value_tab_SOS
WHERE ( a~bundle_id = 'GSS_SEC' AND h~sessitype = 'GS' " Guided SOS
OR a~bundle_id = 'SEC' AND h~sessitype = 'SC' ) " Normal SOS
AND a~dbid IN @dbid
AND a~change_date >= @min_change_date
ORDER BY a~dbid ASCENDING, a~change_date DESCENDING.
APPEND value_tab_SOS.
"SORT value_tab_SOS BY dbid ASCENDING change_date DESCENDING.
ENDSELECT.
retfield = l_dynprofield.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'SESSNO' "retfield "(I do not know why this works better)
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = l_dynprofield
value_org = 'S'
TABLES
* field_tab = field_tab
value_tab = value_tab_SOS
"dynpfld_mapping = field_mapping
EXCEPTIONS
parameter_error = 1
no_values_found = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDFORM. "F4_SESSNO
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON p_layout
*----------------------------------------------------------------------*
DATA: gs_alv_lout_variant TYPE disvariant.
AT SELECTION-SCREEN ON p_layout.
CHECK NOT p_layout IS INITIAL.
PERFORM handle_at_selscr_on_p_layout USING p_layout sy-repid 'A'.
*
FORM handle_at_selscr_on_p_layout
USING id_varname TYPE disvariant-variant
id_repid TYPE sy-repid
id_save TYPE c.
DATA: ls_variant TYPE disvariant.
ls_variant-report = id_repid.
ls_variant-variant = id_varname.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = id_save
CHANGING
cs_variant = ls_variant
EXCEPTIONS
wrong_input = 1
not_found = 2
program_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Selected layout variant is not found
MESSAGE e204(0k).
ENDIF.
gs_alv_lout_variant-report = id_repid.
gs_alv_lout_variant-variant = id_varname.
ENDFORM. " handle_at_selscr_on_p_layout
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout. " ( Note 890141 )
PERFORM handle_at_selscr_f4_p_layout USING sy-repid 'A'
CHANGING p_layout.
*
FORM handle_at_selscr_f4_p_layout
USING id_repid TYPE sy-repid
id_save TYPE c
CHANGING ed_varname TYPE disvariant-variant.
gs_alv_lout_variant-report = id_repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = gs_alv_lout_variant
i_save = id_save
IMPORTING
es_variant = gs_alv_lout_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.
ed_varname = gs_alv_lout_variant-variant.
ELSE.
MESSAGE s073(0k).
* Keine Anzeigevariante(n) vorhanden
ENDIF.
ENDFORM. " handle_at_selscr_f4_p_layout
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST FOR rating
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR rating-low.
PERFORM f4_rating USING 'RATING-LOW'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR rating-high.
PERFORM f4_rating USING 'RATING-HIGH'.
FORM f4_rating
USING
l_dynprofield TYPE help_info-dynprofld.
DATA:
retfield TYPE dfies-fieldname,
"dynpro_values TYPE TABLE OF dynpread,
"field_value LIKE LINE OF dynpro_values,
"field_tab TYPE TABLE OF dfies WITH HEADER LINE,
field_mapping TYPE STANDARD TABLE OF dselc,
BEGIN OF value_tab OCCURS 0,
rating TYPE text15,
END OF value_tab.
" Ratings
value_tab-rating = 'red'(R01). APPEND value_tab. " @AG@
value_tab-rating = 'yellow'(R02). APPEND value_tab. " @AH@
value_tab-rating = 'green'(R03). APPEND value_tab. " @01@
value_tab-rating = 'information'(R04). APPEND value_tab. " @0S@
value_tab-rating = 'not rated'(R05). APPEND value_tab. " @BZ@
value_tab-rating = 'unknown'(R06). APPEND value_tab. " others
" Count of users
value_tab-rating = 'all'(R07). APPEND value_tab.
value_tab-rating = 'valid'(R08). APPEND value_tab.
value_tab-rating = 'locked'(R09). APPEND value_tab.
value_tab-rating = 'outdated'(R10). APPEND value_tab.
retfield = l_dynprofield.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'RATING' "retfield "(i do not know why this works better)
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = l_dynprofield
value_org = 'S'
TABLES
* field_tab = field_tab
value_tab = value_tab
"dynpfld_mapping = field_mapping
EXCEPTIONS
parameter_error = 1
no_values_found = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. "F4_SESSNO
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* Authority check for Service Package, Session and Report
AUTHORITY-CHECK OBJECT 'D_SVAS_SES'
ID 'SES_GR_TYP' FIELD c_ses_gr_typ
ID 'PKG_ID_TYP' FIELD c_pkg_id_typ
ID 'ACTVT_SES' FIELD 'R3' " Display Reports
ID 'AUTHGROUP' FIELD 'R'. " Restricted Authorization
IF sy-subrc IS NOT INITIAL.
"message e425(dsvas). " No authorization to display a session
MESSAGE e430(dsvas). " No authorization to display a report
ENDIF.
* Authorization check for LMDB Object (needs repetition as soon as the system id is known)
AUTHORITY-CHECK OBJECT 'AI_LMDB_OB'
ID 'ACTVT' FIELD '03' " display
ID 'LMDB_DOMA' FIELD 'LDB'
ID 'LMDB_NAMES' FIELD 'ACTIVE'
ID 'LMDB_MTYPE' FIELD 'TECSYS'
ID 'LMDB_STYPE' DUMMY " system type ABAP, HANA,...
ID 'LMDB_OBJID' DUMMY. " System id
IF sy-subrc IS NOT INITIAL.
"message e073(ai_lmdb_external) with sy-uname 'display' 'ABAP'. "User &1 is not authorized for activity '&2' for techn. systems of type &3
"message e425(dsvas). " No authorization to display a session
MESSAGE e430(dsvas). " No authorization to display a report
ENDIF.
PERFORM get_sessions.
PERFORM show_alv.
*&---------------------------------------------------------------------*
FORM get_sessions.
" load sessions
DATA lt_dsvassessadmin TYPE TABLE OF dsvassessadmin.
IF s_ewa = 'X'.
SELECT
h~sessitype,
"h~sessno,
"h~change_user,
"h~change_date,
a~bundle_id,
"a~bundle_versnr,
a~sessno,
a~instno,
a~dbid,
a~change_date,
a~creation_date,
a~description
FROM dsvassessionhead AS h
JOIN dsvassessadmin AS a
ON a~sessno = h~sessno
JOIN dsvasresultsgen AS r " Only sessions having results
ON r~relid = @c_relid " Check tables
AND r~sessitype = h~sessitype " Session type
AND r~sessno = h~sessno " Session number
AND r~grp = @c_grp " Rating overview
AND r~id = @c_id " Rating overview, get it either from check 00013 or from check 00011
AND r~srtf2 = 0 " first entry
INTO CORRESPONDING FIELDS OF TABLE @lt_dsvassessadmin
WHERE ( a~bundle_id = @c_bundle_id AND h~sessitype = @c_sessitype )
AND a~sessno IN @sessno
AND a~instno IN @instno
AND a~dbid IN @dbid
AND a~change_date IN @chgdate
AND a~creation_date IN @credate
ORDER BY a~dbid, a~instno, a~change_date DESCENDING " allow filtering for latest session per system
.
ELSEIF s_sos = 'X'.
SELECT
h~sessitype,
"h~sessno,
"h~change_user,
"h~change_date,
a~bundle_id,
"a~bundle_versnr,
a~sessno,
a~instno,
a~dbid,
a~change_date,
a~creation_date,
a~description
FROM dsvassessionhead AS h
JOIN dsvassessadmin AS a
ON a~sessno = h~sessno
JOIN dsvasresultsgen AS r " Only sessions having results
ON r~relid = @c_relid " Check tables
AND r~sessitype = h~sessitype " Session type
AND r~sessno = h~sessno " Session number
AND r~grp = @c_grp " Rating overview
AND r~id = @c_id " Rating overview, get it either from check 00013 or from check 00011
AND r~srtf2 = 0 " first entry
INTO CORRESPONDING FIELDS OF TABLE @lt_dsvassessadmin
WHERE ( a~bundle_id = 'GSS_SEC' AND h~sessitype = 'GS' " Guided SOS
OR a~bundle_id = 'SEC' AND h~sessitype = 'SC' ) " Normal SOS
AND a~sessno IN @sessno
AND a~instno IN @instno
AND a~dbid IN @dbid
AND a~change_date IN @chgdate
AND a~creation_date IN @credate
ORDER BY a~dbid, a~instno, a~change_date DESCENDING " allow filtering for latest session per system
.
ENDIF.
" process sessions
CLEAR ls_outtab.
LOOP AT lt_dsvassessadmin INTO DATA(ls_dsvassessadmin).
IF p_new = abap_true.
CHECK ls_dsvassessadmin-instno NE ls_outtab-instno
OR ls_dsvassessadmin-dbid NE ls_outtab-dbid
OR ls_dsvassessadmin-change_date > ls_outtab-change_date.
ENDIF.
ls_outtab-instno = ls_dsvassessadmin-instno.
ls_outtab-dbid = ls_dsvassessadmin-dbid.
ls_outtab-sessno = ls_dsvassessadmin-sessno.
ls_outtab-bundle_id = ls_dsvassessadmin-bundle_id.
ls_outtab-sessitype = ls_dsvassessadmin-sessitype.
ls_outtab-change_date = ls_dsvassessadmin-change_date.
ls_outtab-creation_date = ls_dsvassessadmin-creation_date.
PERFORM get_resultsgen
USING
ls_dsvassessadmin.
ENDLOOP.
ENDFORM.
FORM get_resultsgen
USING
ls_dsvassessadmin TYPE dsvassessadmin.
DATA:
ls_dsvasresultsgen TYPE dsvasresultsgen,
lt_dsvasresultsgen TYPE TABLE OF dsvasresultsgen.
IF s_ewa = 'X'. " Show data from check 00018 Alert Overview and Service Summary, too
SELECT * FROM dsvasresultsgen INTO TABLE @lt_dsvasresultsgen
WHERE relid = @c_relid
AND sessitype = @ls_dsvassessadmin-sessitype
AND sessno = @ls_dsvassessadmin-sessno
AND grp = @c_grp
AND id = '00018' " c_id = 00003 Check Overview, 00018 Alert Overview and Service Summary
AND srtf2 = 0 " first entry
ORDER BY relid, sessitype, sessno, grp, id, con, ins, varkey, srtf2
.
LOOP AT lt_dsvasresultsgen INTO ls_dsvasresultsgen.
PERFORM get_check_table
USING ls_dsvasresultsgen.
ENDLOOP.
ENDIF.
IF s_sos = 'X'. " Show data from check 00021 Client Overview, too
" Show additional entries only if selected
if 'Overview'(014) in main
and 'Count of users in requested clients'(015) in chapter
and 'SC_INIT' in chkgrp
and (
'All users'(016) in chk
or 'Valid users'(017) in chk
or 'Locked users'(018) in chk
or 'Outdated users'(019) in chk
)
and '' in sos_id
.
SELECT * FROM dsvasresultsgen INTO TABLE @lt_dsvasresultsgen
WHERE relid = @c_relid
AND sessitype = @ls_dsvassessadmin-sessitype
AND sessno = @ls_dsvassessadmin-sessno
AND grp = 'SC_INIT'
AND id = '00021' " Client Overview
AND srtf2 = 0 " first entry
ORDER BY relid, sessitype, sessno, grp, id, con, ins, varkey, srtf2
.
LOOP AT lt_dsvasresultsgen INTO ls_dsvasresultsgen.
PERFORM get_check_table
USING ls_dsvasresultsgen.
ENDLOOP.
ENDIF.
ENDIF.
" Show overview about check
SELECT * FROM dsvasresultsgen INTO TABLE @lt_dsvasresultsgen
WHERE relid = @c_relid
AND sessitype = @ls_dsvassessadmin-sessitype
AND sessno = @ls_dsvassessadmin-sessno
AND grp = @c_grp
AND id = @c_id
AND srtf2 = 0 " first entry
ORDER BY relid, sessitype, sessno, grp, id, con, ins, varkey, srtf2
.
LOOP AT lt_dsvasresultsgen INTO ls_dsvasresultsgen.
PERFORM get_check_table
USING ls_dsvasresultsgen.
ENDLOOP.
ENDFORM.
FORM get_check_table
USING
ls_dsvasresultsgen TYPE dsvasresultsgen.
DATA :
results_key TYPE dsvasresultsgenkey. " key for IMPORT ... FROM DATABASE dsvasresultsgen(ct)
" metadata table
TYPES :
BEGIN OF type_check_table_meta_h_data,
columns TYPE dsvastable-columns,
column_metadata TYPE dsvas_type_ct_col_meta_table,
title TYPE dsvastablet-text,
action TYPE dsvastable-action,
fixed_columns TYPE dsvastable-fixed_columns,
invisible TYPE dsvastable-invisible,
in_report TYPE c,
edit_mode TYPE dsvastable-edit_mode,
END OF type_check_table_meta_h_data,
type_check_table_meta_h_table TYPE STANDARD TABLE OF type_check_table_meta_h_data.
DATA :
lt_metadata_h TYPE type_check_table_meta_h_table.
" data tables
DATA :
table_data TYPE dsvas_type_tables_data_table, " contains STRING
table_data_s TYPE dsvas_type_tables_data_table_s. " contains CHAR120
" Build the check key
results_key-sessitype = ls_dsvasresultsgen-sessitype.
results_key-sessno = ls_dsvasresultsgen-sessno.
results_key-versnr = ls_dsvasresultsgen-versnr.
results_key-grp = ls_dsvasresultsgen-grp.
results_key-id = ls_dsvasresultsgen-id.
results_key-con = ls_dsvasresultsgen-con.
results_key-ins = ls_dsvasresultsgen-ins.
IMPORT
table_data_ext = table_data " contains STRING
table_data = table_data_s " contains CHAR120
metadata = lt_metadata_h " column headings
FROM DATABASE dsvasresultsgen(ct)
ID results_key
IGNORING CONVERSION ERRORS
ACCEPTING PADDING
ACCEPTING TRUNCATION.
IF sy-subrc = 0.
IF s_ewa = 'X'.
PERFORM process_ewa_table
USING
ls_dsvasresultsgen-grp
ls_dsvasresultsgen-id
table_data
.
ELSEIF s_sos = 'X'.
IF ls_dsvasresultsgen-grp = 'SC_INIT' and ls_dsvasresultsgen-id = '00021'.
"ls_outtab-instno
"ls_outtab-dbid
"ls_outtab-sessno
"ls_outtab-change_date
"ls_outtab-creation_date
ls_outtab-row = 0.
ls_outtab-main_chapter = ''.
ls_outtab-chapter = ''.
ls_outtab-check = ''.
ls_outtab-alert_id = ''.
ls_outtab-sos_check_id = ''.
ls_outtab-rating = ''.
ls_outtab-rating_text = ''.
ls_outtab-count = 0.
ls_outtab-check_group = ls_dsvasresultsgen-grp.
ls_outtab-check_id = ls_dsvasresultsgen-id.
ls_outtab-con = ls_dsvasresultsgen-con.
ls_outtab-ins = ls_dsvasresultsgen-ins.
PERFORM process_sos_client_count_table
USING
ls_dsvasresultsgen-grp
ls_dsvasresultsgen-id
table_data
.
ELSE.
PERFORM process_sos_table
USING
ls_dsvasresultsgen-grp
ls_dsvasresultsgen-id
table_data
.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
FORM process_ewa_table
USING
check_group TYPE dsvasdcheckgrp
check_id TYPE dsvasdcheckid
table_data TYPE dsvas_type_tables_data_table
.
DATA rating_tabix TYPE i.
rating_tabix = 2.
" get meta data for ratings (column headings, not used yet)
"READ TABLE lt_metadata_h INTO DATA(ls_metadata_h) INDEX rating_tabix.
" get check table for ratings
READ TABLE table_data INTO DATA(lt_rating_table) INDEX rating_tabix.
LOOP AT lt_rating_table INTO DATA(ls_rating_entry).
ls_outtab-row = ls_rating_entry-row.
CLEAR:
"ls_outtab-main_chapter, " Keep text from previous line
ls_outtab-chapter,
ls_outtab-check,
ls_outtab-alert_id,
"ls_outtab-sos_check_id, "not used for EWA
ls_outtab-rating,
ls_outtab-rating_text,
"ls_outtab-count, "not used for EWA
ls_outtab-check_group,
ls_outtab-check_id,
ls_outtab-con,
ls_outtab-ins.
LOOP AT ls_rating_entry-columns INTO DATA(ls_rating_column).
IF check_id = '00018'.
" EA_HEAD Check 00018 Table 2 Alert Overview and Service Summary
" main_chapter = 'Alerts'
" 1 Rating rating / rating_text
" 2 Description check
" 3 Category chapter
" 4 Area
" 5 Context con
" 6 Instance ins
" 7 Alert ID sos_check_id
" 8 Check group check_group
" 9 Check ID check_id
" 10 Referenced group
" 11 Priority
ls_outtab-main_chapter = 'Alerts'(013).
CASE ls_rating_column-col.
WHEN 1. " Rating
ls_outtab-rating = ls_rating_column-field.
" Get rating text
PERFORM get_rating_text
USING
ls_outtab-rating
CHANGING
ls_outtab-rating_text.
WHEN 2. " Description
FIND REGEX '<.*>(.*)<.*>' " find text '<[^>]*>([^<]*)<[^>]*>' or '<.*>(.*)<.*>'
IN ls_rating_column-field
SUBMATCHES ls_outtab-check.
WHEN 3. " Category
ls_outtab-chapter = ls_rating_column-field.
WHEN 4. " Area
"concatenate ls_outtab-chapter ls_rating_column-field into ls_outtab-chapter SEPARATED BY space.
WHEN 5. " Context
ls_outtab-con = ls_rating_column-field.
WHEN 6 . " Instance
ls_outtab-ins = ls_rating_column-field.
WHEN 7 . " Alert ID
ls_outtab-alert_id = ls_rating_column-field.
WHEN 8. " Check group
ls_outtab-check_group = ls_rating_column-field.
WHEN 9. " Check ID
ls_outtab-check_id = ls_rating_column-field.
WHEN 10. " Referenced group
WHEN 11. " Priority
"concatenate ls_outtab-chapter ls_rating_column-field into ls_outtab-chapter SEPARATED BY space.
ENDCASE.
ELSEIF check_id = '00003'.
" EA_HEAD Check 00003 Table 2 Check overview
" 1 Topic Rating
" 2 Topic
" 3 Check-GRP
" 4 Check-ID
" 5 Context
" 6 Instance
" 7 Subtopic Rating
" 8 Subtopic
" 9 Check-GRP
" 10 Check-ID
" 11 Context
" 12 Instance
CASE ls_rating_column-col.
WHEN 1 OR 7. " Rating
ls_outtab-rating = ls_rating_column-field.
" Get rating text
PERFORM get_rating_text
USING
ls_outtab-rating
CHANGING
ls_outtab-rating_text.
WHEN 2. " Topic
FIND REGEX '<.*>(.*)<.*>' " find text '<[^>]*>([^<]*)<[^>]*>' or '<.*>(.*)<.*>'
IN ls_rating_column-field
SUBMATCHES ls_outtab-main_chapter.
WHEN 8. " Sub topic
FIND REGEX '<.*>(.*)<.*>' " find text '<[^>]*>([^<]*)<[^>]*>' or '<.*>(.*)<.*>'
IN ls_rating_column-field
SUBMATCHES ls_outtab-chapter.
WHEN 3 OR 9. " Check-GRP
ls_outtab-check_group = ls_rating_column-field.
WHEN 4 OR 10. " Check-ID
ls_outtab-check_id = ls_rating_column-field.
WHEN 5 OR 11. " Context
ls_outtab-con = ls_rating_column-field.
WHEN 6 OR 12. " Instance
ls_outtab-ins = ls_rating_column-field.
ENDCASE.
ENDIF.
ENDLOOP. " ls_rating_entry-columns
" Filter
CHECK ls_outtab-main_chapter IN main
AND ls_outtab-chapter IN chapter
AND ls_outtab-check IN chk
AND ls_outtab-alert_id IN ewa_id
"AND ls_outtab-sos_check_id IN sos_id " not used for EWA
AND ls_outtab-check_group IN chkgrp
"AND ls_outtab-check_id IN chkid
AND ls_outtab-rating_text IN rating.
APPEND ls_outtab TO lt_outtab.
ENDLOOP. " lt_rating_table
ENDFORM.