-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathzcheck_note_3089413.prog.abap
3941 lines (3297 loc) · 164 KB
/
zcheck_note_3089413.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 ZCHECK_NOTE_3089413
*& Check implementation status of note 3089413 for connected ABAP systems
*&---------------------------------------------------------------------*
*& Author: Frank Buchholz, SAP CoE Security Services
*& Source: https://github.com/SAP-samples/security-services-tools
*&
*& 08.09.2023 SLIN corrections
*& 06.07.2023 Typo in text corrected
*& 29.06.2023 Updated Kernel prerequisites as described in note 3224161
*& Updated Note prerequisites for note 3287611 v9
*& 28.03.2023 New check about generic authorizations for S_RFCACL (configuration in CCDB needed)
*& 13.03.2023 Updated note 3287611, new note 3304520
*& 27.02.2023 Check version of installed notes, small corrections
*& 16.02.2023 Show count of migrated trusted destinations per trust relation
*& ABAPLINT corrections, optimized performance
*& 15.02.2023 Show more details about destinations
*& 14.02.2023 A double click on a count of destinations shows a popup with the details
*& 13.02.2023 Refactoring to use local methods instead of forms
*& 07.02.2023 Show trusted systems without any data in RFCSYSACL
*& Show mutual trust relations
*& 06.02.2023 New result field to indicate explicit selftrust defined in SMT1
*& A double click on a count of trusted systems shows a popup with the details
*& 02.02.2023 Check destinations, too
*& 02.02.2023 Initial version
*&---------------------------------------------------------------------*
REPORT zcheck_note_3089413.
CONSTANTS c_program_version(30) TYPE c VALUE '08.09.2023 FBT'.
TYPE-POOLS: icon, col, sym.
* System name
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) ss_sid FOR FIELD p_sid.
SELECT-OPTIONS p_sid FOR ('DIAGLS_TECH_SYST_LONG_SID').
SELECTION-SCREEN END OF LINE.
* Check Kernel
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_kern AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(80) ps_kern FOR FIELD p_kern.
SELECTION-SCREEN END OF LINE.
* Check ABAP
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_abap AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(80) ps_abap FOR FIELD p_abap.
SELECTION-SCREEN END OF LINE.
* Check trusted relations
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_trust AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(80) ps_trust FOR FIELD p_trust.
SELECTION-SCREEN END OF LINE.
* Check trusted destinations
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_dest AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(80) ps_dest FOR FIELD p_dest.
SELECTION-SCREEN END OF LINE.
* Show specific type only if data found
DATA p_dest_3 TYPE abap_bool.
DATA p_dest_h TYPE abap_bool.
DATA p_dest_w TYPE abap_bool.
* Check user authorizations for S_RFCACL
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_auth AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN COMMENT 3(80) ps_auth FOR FIELD p_auth.
SELECTION-SCREEN END OF LINE.
* Store status
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) ss_state FOR FIELD p_state.
SELECT-OPTIONS p_state FOR ('DIAGST_MAIN_STATE_TYPE') VISIBLE LENGTH 1." DEFAULT 'G'.
SELECTION-SCREEN END OF LINE.
* Layout of ALV output
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) ps_lout FOR FIELD p_layout.
PARAMETERS p_layout TYPE disvariant-variant.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN COMMENT /1(60) ss_vers.
*---------------------------------------------------------------------*
" Main result table
TYPES:
BEGIN OF ts_result,
" Assumption: Match entries from different stores based on install_number and landscape_id
install_number TYPE sdiagst_store_dir-install_number,
long_sid TYPE diagls_tech_syst_long_sid, "sdiagst_store_dir-long_sid,
sid TYPE diagls_technical_system_sid, "sdiagst_store_dir-sid,
tech_system_type TYPE diagls_technical_system_type, "sdiagst_store_dir-tech_system_type,
tech_system_id TYPE diagls_id, "sdiagst_store_dir-tech_system_id,
landscape_id TYPE diagls_id, "sdiagst_store_dir-landscape_id,
host_full TYPE diagls_host_full_name, "sdiagst_store_dir-host_full,
host TYPE diagls_host_name, "sdiagst_store_dir-host,
host_id TYPE diagls_id, "sdiagst_store_dir-host_id,
physical_host TYPE diagls_host_name, "sdiagst_store_dir-physical_host,
instance_type TYPE diagls_instance_type, "sdiagst_store_dir-instance_type,
instance TYPE diagls_instance_name, "sdiagst_store_dir-instance,
" Source store: SAP_KERNEL
kern_rel TYPE string, " 722_EXT_REL
kern_patchlevel TYPE string, " 1000
kern_comp_time TYPE string, " Jun 7 2020 15:44:10
kern_comp_date TYPE sy-datum,
validate_kernel TYPE string,
" Source store: ABAP_COMP_SPLEVEL
compv_name TYPE sdiagst_store_dir-compv_name, " Software Component Version
abap_release TYPE string, " 754
abap_sp TYPE string, " 0032
validate_abap TYPE string,
" Source store: ABAP_NOTES
note_3089413 TYPE string,
note_3089413_prstatus TYPE cwbprstat,
note_3287611 TYPE string,
note_3287611_prstatus TYPE cwbprstat,
note_3304520 TYPE string,
note_3304520_prstatus TYPE cwbprstat,
" Source store: RFCSYSACL
trustsy_cnt_all TYPE i,
no_data_cnt TYPE i,
mutual_trust_cnt TYPE i,
trustsy_cnt_tcd TYPE i,
trustsy_cnt_3 TYPE i,
trustsy_cnt_2 TYPE i,
trustsy_cnt_1 TYPE i,
explicit_selftrust TYPE string,
" Source store: ABAP_INSTANMCE_PAHI
rfc_selftrust TYPE string,
rfc_allowoldticket4tt TYPE string,
rfc_sendinstnr4tt TYPE string,
" Source store: RFCDES
dest_3_cnt_all TYPE i,
dest_3_cnt_trusted TYPE i,
dest_3_cnt_trusted_migrated TYPE i,
dest_3_cnt_trusted_no_instnr TYPE i,
dest_3_cnt_trusted_no_sysid TYPE i,
dest_3_cnt_trusted_snc TYPE i,
dest_h_cnt_all TYPE i,
dest_h_cnt_trusted TYPE i,
dest_h_cnt_trusted_migrated TYPE i,
dest_h_cnt_trusted_no_instnr TYPE i,
dest_h_cnt_trusted_no_sysid TYPE i,
dest_h_cnt_trusted_tls TYPE i,
dest_w_cnt_all TYPE i,
dest_w_cnt_trusted TYPE i,
dest_w_cnt_trusted_migrated TYPE i,
dest_w_cnt_trusted_no_instnr TYPE i,
dest_w_cnt_trusted_no_sysid TYPE i,
dest_w_cnt_trusted_tls TYPE i,
" Source store: AUTH_COMB_CHECK_USER (users having generic authorizations for S_RFCACL)
s_rfcacl_status TYPE string,
s_rfcacl_active_users TYPE i,
s_rfcacl_inactive_users TYPE i,
" Source store: we show the status of the first found store only which is usually store SAP_KERNEL
store_name TYPE sdiagst_store_dir-store_name,
store_id TYPE sdiagst_store_dir-store_id,
store_last_upload TYPE sdiagst_store_dir-store_last_upload,
store_state TYPE sdiagst_store_dir-store_state, " CMPL = ok
store_main_state_type TYPE sdiagst_store_dir-store_main_state_type, " (G)reen, (Y)ello, (R)ed, (N)ot relevant
store_main_state TYPE sdiagst_store_dir-store_main_state,
store_outdated_day TYPE sdiagst_store_dir-store_outdated_day,
t_color TYPE lvc_t_scol,
"t_celltype type salv_t_int4_column,
"T_HYPERLINK type SALV_T_INT4_COLUMN,
"t_dropdown type salv_t_int4_column,
END OF ts_result,
tt_result TYPE STANDARD TABLE OF ts_result.
" Popup showing trusted systems
TYPES:
BEGIN OF ts_rfcsysacl_data,
rfcsysid TYPE rfcssysid, " Trusted system
tlicense_nr TYPE slic_inst, " Installation number of trusted system
rfctrustsy TYPE rfcssysid, " Trusting system (=current system)
llicense_nr TYPE slic_inst, " Installation number of trusting system (=current system), only available in higher versions
rfcslopt TYPE rfcslopt, " Options respective version
no_data TYPE string, " No data found for trusted system
mutual_trust TYPE string, " Mutual trust relation
rfcdest TYPE rfcdest, " Destination to trusted system
rfccredest TYPE rfcdest, " Destination, only available in higher versions
rfcregdest TYPE rfcdest, " Destination, only available in higher versions
rfcsnc TYPE rfcsnc, " SNC respective TLS
rfcseckey TYPE rfcticket, " Security key (empty or '(stored)'), only available in higher versions
rfctcdchk TYPE rfctcdchk, " Tcode check
trusted_dest_cnt TYPE i, " Count of migrated trusted destinations in trusted system
t_color TYPE lvc_t_scol,
END OF ts_rfcsysacl_data,
tt_rfcsysacl_data TYPE STANDARD TABLE OF ts_rfcsysacl_data WITH KEY rfcsysid tlicense_nr,
BEGIN OF ts_trusted_system,
rfctrustsy TYPE rfcssysid, " Trusting system (=current system)
llicense_nr TYPE slic_inst, " Installation number of trusting system
rfcsysacl_data TYPE tt_rfcsysacl_data,
END OF ts_trusted_system,
tt_trusted_systems TYPE STANDARD TABLE OF ts_trusted_system WITH KEY rfctrustsy llicense_nr.
" Popup showing destinations
TYPES:
BEGIN OF ts_destination_data,
rfcdest TYPE rfcdest,
rfctype TYPE rfctype_d,
trusted(1), " Flag for Trusted RFC
rfcslogin TYPE rfcslogin, " Logon Procedure
serversysid TYPE rfcsysid, " System ID of target system
serverinstnr TYPE slic_inst, " Installation number of target system
check_trusted TYPE string, " Check trusted relation in trusting system
rfchost TYPE rfchost_ext, " Name of Target Host
rfcservice TYPE rfcservice, " Service used (TCP service, SAP System number)
rfcsysid TYPE rfcsysid, " System ID
rfcclient TYPE rfcclient, " Explicit logon client
rfcsameusr TYPE rfcsameusr, " Current User
rfcuser TYPE rfcuser, " Explicit user ID
rfcauth TYPE rfcauth, " Explicit password
rfcsnc TYPE rfcsnc, " RFC Secure Network Communication (HTTP SSL)
sslapplic TYPE ssfapplssl, " SSL Client Identity
noccert TYPE char1, " No client cert
t_color TYPE lvc_t_scol,
END OF ts_destination_data,
tt_destination_data TYPE STANDARD TABLE OF ts_destination_data WITH KEY rfcdest,
BEGIN OF ts_destination,
sid TYPE diagls_technical_system_sid, "sdiagst_store_dir-sid,
install_number TYPE sdiagst_store_dir-install_number,
destination_data TYPE tt_destination_data,
END OF ts_destination,
tt_destinations TYPE STANDARD TABLE OF ts_destination WITH KEY sid install_number.
" Popup showing users
TYPES:
BEGIN OF ts_user_data,
client TYPE usr02-mandt,
rc TYPE string,
user TYPE usr02-bname,
locked(1),
invalid(1),
user_type TYPE string,
user_group TYPE usr02-class,
END OF ts_user_data,
tt_user_data TYPE STANDARD TABLE OF ts_user_data WITH KEY client user,
BEGIN OF ts_critical_user,
sid TYPE diagls_technical_system_sid, "sdiagst_store_dir-sid,
install_number TYPE sdiagst_store_dir-install_number,
user_data TYPE tt_user_data,
END OF ts_critical_user,
tt_critical_users TYPE STANDARD TABLE OF ts_critical_user WITH KEY sid install_number.
*---------------------------------------------------------------------*
* CLASS lcl_report DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_report DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
initialization,
f4_s_sid,
f4_p_layout
CHANGING layout TYPE disvariant-variant,
at_selscr_on_p_layout
IMPORTING layout TYPE disvariant-variant,
start_of_selection.
PRIVATE SECTION.
CLASS-DATA:
" main data table
lt_result TYPE tt_result,
" details about trust relations
lt_trusted_systems TYPE tt_trusted_systems,
" details about destinations
lt_destinations TYPE tt_destinations,
" details about users
lt_critical_users TYPE tt_critical_users.
CLASS-DATA:
" main ALV table
lr_alv_table TYPE REF TO cl_salv_table,
" for handling the events on the main ALV table
lr_alv_events TYPE REF TO lcl_report.
CLASS-METHODS:
get_sap_kernel,
" Convert text like 'Dec 7 2020' into a date field
convert_comp_time
IMPORTING comp_time TYPE string
RETURNING VALUE(comp_date) TYPE sy-datum,
get_abap_comp_splevel,
get_abap_notes,
get_rfcsysacl,
get_rfcdes,
get_abap_instance_pahi,
get_authorizations,
validate_kernel,
validate_abap,
validate_mutual_trust,
count_dest_per_trust,
validate_trust_for_dest,
validate_authorizations,
show_result,
on_user_command FOR EVENT added_function OF cl_salv_events
IMPORTING e_salv_function,
on_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column,
* on_single_click for event link_click of cl_salv_events_table
* importing row column,
show_trusted_systems
IMPORTING
column TYPE salv_de_column
rfctrustsy TYPE ts_result-sid
llicense_nr TYPE ts_result-install_number,
show_destinations
IMPORTING
column TYPE salv_de_column
sid TYPE ts_result-sid
install_number TYPE ts_result-install_number,
show_critical_users
IMPORTING
column TYPE salv_de_column
sid TYPE ts_result-sid
install_number TYPE ts_result-install_number.
ENDCLASS. "lcl_report DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_report IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_report IMPLEMENTATION.
METHOD initialization.
sy-title = 'Check implementation status of note 3089413 for connected ABAP systems'(TIT).
ss_sid = 'System'.
ss_state = 'Config. store status (G/Y/R)'.
ps_kern = 'Check Kernel'.
ps_abap = 'Check Support Package and Notes'.
ps_trust = 'Check Trusted Relations (in server systems)'.
ps_dest = 'Check Trusted Destinations (in client systems)'.
ps_auth = 'Check critical authorizations for S_RFCACL (configuration needed)'.
ps_lout = 'Layout'.
CONCATENATE 'Program version:'(ver) c_program_version INTO ss_vers
SEPARATED BY space.
ENDMETHOD. " initialization
METHOD f4_s_sid.
TYPES:
BEGIN OF ts_f4_value,
long_sid TYPE diagls_tech_syst_long_sid, "sdiagst_store_dir-long_sid,
"sid TYPE diagls_technical_system_sid, "sdiagst_store_dir-sid,
"tech_system_id TYPE diagls_id, "sdiagst_store_dir-tech_system_id,
install_number TYPE diagls_tech_syst_install_nbr,
itadmin_role TYPE diagls_itadmin_role,
END OF ts_f4_value.
DATA:
f4_value TYPE ts_f4_value,
f4_value_tab TYPE TABLE OF ts_f4_value.
DATA:
lt_technical_systems TYPE tt_diagst_tech_syst,
rc TYPE i,
rc_text TYPE natxt.
CALL FUNCTION 'DIAGST_GET_TECH_SYSTEMS'
EXPORTING
namespace = 'ACTIVE'
* LONG_SID =
tech_type = 'ABAP'
* INSTALL_NUMBER =
* TECH_SYST_ID =
* DIAG_RELEVANT = 'X'
* STATS_FROM =
* STATS_TO =
* DISPLAY = ' ' " Only useful if the function is manually executed by transaction SE37.
" Setting this parameter to 'X' will display the result.
* CALLING_APPL = ' '
IMPORTING
technical_systems = lt_technical_systems
* STATS =
rc = rc
rc_text = rc_text.
LOOP AT lt_technical_systems INTO DATA(ls_technical_systems).
MOVE-CORRESPONDING ls_technical_systems TO f4_value.
APPEND f4_value TO f4_value_tab.
ENDLOOP.
SORT f4_value_tab BY long_sid.
DATA(progname) = sy-repid.
DATA(dynnum) = sy-dynnr.
DATA field TYPE dynfnam.
DATA stepl TYPE sy-stepl.
GET CURSOR FIELD field LINE stepl.
DATA return_tab TYPE TABLE OF ddshretval.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'LONG_SID'
dynpprog = progname
dynpnr = dynnum
dynprofield = field
stepl = stepl
value_org = 'S'
TABLES
* field_tab = field_tab
value_tab = f4_value_tab
return_tab = return_tab " surprisingly required to get lower case values
EXCEPTIONS
parameter_error = 1
no_values_found = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDMETHOD. " f4_s_sid
METHOD f4_p_layout.
"CHANGING layout TYPE disvariant-variant.
DATA ls_alv_variant TYPE disvariant.
ls_alv_variant-report = sy-repid.
ls_alv_variant-variant = layout.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = ls_alv_variant
i_save = 'A'
IMPORTING
es_variant = ls_alv_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.
layout = ls_alv_variant-variant.
ELSE.
MESSAGE s073(0k). " Keine Anzeigevariante(n) vorhanden
ENDIF.
ENDMETHOD. " f4_p_layout
METHOD at_selscr_on_p_layout.
"IMPORTING layout TYPE disvariant-variant.
DATA: ls_variant TYPE disvariant.
ls_variant-report = sy-repid.
ls_variant-variant = layout.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = 'A'
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.
ENDMETHOD. " at_selscr_on_p_layout
METHOD start_of_selection.
get_sap_kernel( ). " Kernel version
get_abap_comp_splevel( ). " Support Package version of SAP_BASIS
get_abap_notes( ). " Notes 3089413 and 3287611
get_rfcsysacl( ). " Trusting relations
get_rfcdes( ). " Trusted desinations
get_abap_instance_pahi( ). " rfc/selftrust
get_authorizations( ). " Authorizations for S_RFCACL
validate_kernel( ).
validate_abap( ).
count_dest_per_trust( ).
validate_trust_for_dest( ).
validate_mutual_trust( ).
validate_authorizations( ).
show_result( ).
ENDMETHOD. " start_of_selection
METHOD get_sap_kernel.
CHECK p_kern = 'X'.
" Same as in report ZSHOW_KERNEL_STORES but one one entry per system
DATA:
lt_store_dir_tech TYPE tt_diagst_store_dir_tech,
lt_store_dir TYPE tt_diagst_store_dir,
lt_fieldlist TYPE tt_diagst_table_store_fields,
lt_snapshot TYPE tt_diagst_trows,
rc TYPE i,
rc_text TYPE natxt.
DATA tabix TYPE i.
CALL FUNCTION 'DIAGST_GET_STORES'
EXPORTING
" The "System Filter" parameters allow to get all Stores of a system or technical system.
" Some combinations of the four parameters are not allowed.
" The function will return an error code in such a case.
* SID = ' '
* INSTALL_NUMBER = ' '
* LONG_SID = ' '
* TECH_SYSTEM_TYPE = 'ABAP' "(only together with LONG_SID)
" Store key fields
group_namespace = 'ACTIVE' "(optional)
group_landscape_class = 'CL_DIAGLS_ABAP_INSTANCE' "(optional)
* GROUP_LANDSCAPE_ID = ' '
* GROUP_COMP_ID = ' '
group_source = 'ABAP' "(optional)
group_name = 'INSTANCE' "(optional)
store_category = 'SOFTWARE' "(optional)
store_type = 'PROPERTY' "(optional)
* STORE_FULLPATH = ' '
store_name = 'SAP_KERNEL'
" Special filters
store_mainalias = 'ABAP-SOFTWARE' "(optional)
store_subalias = 'SAP-KERNEL' "(optional)
* STORE_TPL_ID = ' '
* HAS_ELEMENT_FROM = " date range
* HAS_ELEMENT_TO = " date range
* ELEMENT_FILTER = 'C' " (C)hange, (I)nitial, (A)ll
* CASE_INSENSITIVE = ' '
* PATTERN_SEARCH = 'X' " Allow pattern search for SEARCH_STRING
* SEARCH_STRING =
* ONLY_RELEVANT = 'X'
* PROTECTED = 'A' " (N)ot, (Y)es, (A)ll
" Others
* DISPLAY = ' ' " Only useful if the function is manually executed by transaction SE37.
" Setting this parameter to 'X' will display the result.
* CALLING_APPL = ' '
IMPORTING
* STORE_DIR_TECH = lt_STORE_DIR_TECH "(efficient, reduced structure)
store_dir = lt_store_dir "(not recommended anymore)
* STORE_DIR_MI = "(SAP internal usage only)
* STORE_STATS = " History regarding the changes of elements (configuration items).
* PARAMETER = "(SAP internal usage only)
rc = rc
rc_text = rc_text.
IF rc IS NOT INITIAL.
MESSAGE e001(00) WITH rc_text ##MG_MISSING.
ENDIF.
LOOP AT lt_store_dir INTO DATA(ls_store_dir)
WHERE long_sid IN p_sid
AND store_main_state_type IN p_state
.
" Do we already have an entry for this system?
READ TABLE lt_result INTO DATA(ls_result)
WITH KEY
install_number = ls_store_dir-install_number
long_sid = ls_store_dir-long_sid
sid = ls_store_dir-sid
.
IF sy-subrc = 0.
tabix = sy-tabix.
IF ls_store_dir-instance_type NE 'CENTRAL'.
CONTINUE.
ENDIF.
MOVE-CORRESPONDING ls_store_dir TO ls_result.
ELSE.
tabix = -1.
CLEAR ls_result.
MOVE-CORRESPONDING ls_store_dir TO ls_result.
ENDIF.
IF ls_result-host_full IS INITIAL.
ls_result-host_full = ls_result-host. " host, host_id, physical_host
ENDIF.
CALL FUNCTION 'DIAGST_TABLE_SNAPSHOT'
EXPORTING
store_id = ls_store_dir-store_id
* TIMESTAMP = " if not specified the latest available snapshot is returned
* CALLING_APPL = ' '
IMPORTING
fieldlist = lt_fieldlist
* SNAPSHOT_VALID_FROM =
* SNAPSHOT_VALID_TO_CONFIRMED =
* SNAPSHOT_VALID_TO =
snapshot = lt_snapshot " The content of the requested snapshot in ABAP DDIC type format
* SNAPSHOT_TR =
* SNAPSHOT_ITSAM = " The content of the requested snapshot in XML-based format
rc = rc " 3: Permission denied, Content Authorization missing
" 4: Store not existing
" 8: Error
rc_text = rc_text.
LOOP AT lt_snapshot INTO DATA(lt_snapshot_elem).
READ TABLE lt_snapshot_elem INTO DATA(ls_parameter) INDEX 1.
CHECK ls_parameter-fieldname = 'PARAMETER'.
READ TABLE lt_snapshot_elem INTO DATA(ls_value) INDEX 2.
CHECK ls_value-fieldname = 'VALUE'.
CASE ls_parameter-fieldvalue.
WHEN 'KERN_COMP_ON'. " Linux GNU SLES-11 x86_64 cc4.3.4 use-pr190909
" not used yet
WHEN 'KERN_COMP_TIME'. " Jun 7 2020 15:44:10
ls_result-kern_comp_time = ls_value-fieldvalue.
ls_result-kern_comp_date = convert_comp_time( ls_result-kern_comp_time ).
WHEN 'KERN_DBLIB'. " SQLDBC 7.9.8.040
" not used yet
WHEN 'KERN_PATCHLEVEL'. " 1000
ls_result-kern_patchlevel = ls_value-fieldvalue.
WHEN 'KERN_REL'. " 722_EXT_REL
ls_result-kern_rel = ls_value-fieldvalue.
WHEN 'PLATFORM-ID'. " 390
" not used yet
ENDCASE.
ENDLOOP.
IF tabix > 0.
MODIFY lt_result FROM ls_result INDEX tabix.
ELSE.
APPEND ls_result TO lt_result.
ENDIF.
ENDLOOP. " lt_STORE_DIR
ENDMETHOD. " get_SAP_KERNEL
* Convert text like 'Dec 7 2020' into a date field
METHOD convert_comp_time.
"IMPORTING comp_time TYPE string
"RETURNING VALUE(comp_date) TYPE sy-datum
DATA:
text TYPE string,
day(2) TYPE n,
month(2) TYPE n,
year(4) TYPE n.
text = comp_time.
CONDENSE text.
SPLIT text AT space INTO DATA(month_c) DATA(day_c) DATA(year_c) DATA(time_c).
day = day_c.
CASE month_c.
WHEN 'Jan'. month = 1.
WHEN 'Feb'. month = 2.
WHEN 'Mar'. month = 3.
WHEN 'Apr'. month = 4.
WHEN 'May'. month = 5.
WHEN 'Jun'. month = 6.
WHEN 'Jul'. month = 7.
WHEN 'Aug'. month = 8.
WHEN 'Sep'. month = 9.
WHEN 'Oct'. month = 10.
WHEN 'Nov'. month = 11.
WHEN 'Dec'. month = 12.
ENDCASE.
year = year_c.
comp_date = |{ year }{ month }{ day }|.
ENDMETHOD. " convert_comp_time
METHOD get_abap_comp_splevel.
CHECK p_abap = 'X'.
DATA:
lt_store_dir_tech TYPE tt_diagst_store_dir_tech,
lt_store_dir TYPE tt_diagst_store_dir,
lt_fieldlist TYPE tt_diagst_table_store_fields,
lt_snapshot TYPE tt_diagst_trows,
rc TYPE i,
rc_text TYPE natxt.
DATA tabix TYPE i.
" Using a SEARCH_STRING for SAP_BASIS should not speed up processing, as this component exists always
CALL FUNCTION 'DIAGST_GET_STORES'
EXPORTING
" The "System Filter" parameters allow to get all Stores of a system or technical system.
" Some combinations of the four parameters are not allowed.
" The function will return an error code in such a case.
* SID = ' '
* INSTALL_NUMBER = ' '
* LONG_SID = ' '
* TECH_SYSTEM_TYPE = 'ABAP' "(only together with LONG_SID)
" Store key fields
group_namespace = 'ACTIVE' "(optional)
group_landscape_class = 'CL_DIAGLS_ABAP_TECH_SYST' "(optional)
* GROUP_LANDSCAPE_ID = ' '
* GROUP_COMP_ID = ' '
group_source = 'ABAP' "(optional)
group_name = 'ABAP-SOFTWARE' "(optional)
store_category = 'SOFTWARE' "(optional)
store_type = 'TABLE' "(optional)
* STORE_FULLPATH = ' '
store_name = 'ABAP_COMP_SPLEVEL'
" Special filters
store_mainalias = 'ABAP-SOFTWARE' "(optional)
store_subalias = 'SUPPORT-PACKAGE-LEVEL' "(optional)
* STORE_TPL_ID = ' '
* HAS_ELEMENT_FROM = " date range
* HAS_ELEMENT_TO = " date range
* ELEMENT_FILTER = 'C' " (C)hange, (I)nitial, (A)ll
* CASE_INSENSITIVE = ' '
"PATTERN_SEARCH = ' ' " Allow pattern search for SEARCH_STRING
"SEARCH_STRING = 'SAP_BASIS'
* ONLY_RELEVANT = 'X'
* PROTECTED = 'A' " (N)ot, (Y)es, (A)ll
" Others
* DISPLAY = ' ' " Only useful if the function is manually executed by transaction SE37.
" Setting this parameter to 'X' will display the result.
* CALLING_APPL = ' '
IMPORTING
* STORE_DIR_TECH = lt_STORE_DIR_TECH "(efficient, reduced structure)
store_dir = lt_store_dir "(not recommended anymore)
* STORE_DIR_MI = "(SAP internal usage only)
* STORE_STATS = " History regarding the changes of elements (configuration items).
* PARAMETER = "(SAP internal usage only)
rc = rc
rc_text = rc_text.
IF rc IS NOT INITIAL.
MESSAGE e001(00) WITH rc_text ##MG_MISSING.
ENDIF.
LOOP AT lt_store_dir INTO DATA(ls_store_dir)
WHERE long_sid IN p_sid
AND store_main_state_type IN p_state
.
" Do we already have an entry for this system?
READ TABLE lt_result INTO DATA(ls_result)
WITH KEY
install_number = ls_store_dir-install_number
long_sid = ls_store_dir-long_sid
sid = ls_store_dir-sid
.
IF sy-subrc = 0.
tabix = sy-tabix.
ELSE.
tabix = -1.
CLEAR ls_result.
MOVE-CORRESPONDING ls_store_dir TO ls_result.
ENDIF.
CALL FUNCTION 'DIAGST_TABLE_SNAPSHOT'
EXPORTING
store_id = ls_store_dir-store_id
* TIMESTAMP = " if not specified the latest available snapshot is returned
* CALLING_APPL = ' '
IMPORTING
fieldlist = lt_fieldlist
* SNAPSHOT_VALID_FROM =
* SNAPSHOT_VALID_TO_CONFIRMED =
* SNAPSHOT_VALID_TO =
snapshot = lt_snapshot " The content of the requested snapshot in ABAP DDIC type format
* SNAPSHOT_TR =
* SNAPSHOT_ITSAM = " The content of the requested snapshot in XML-based format
rc = rc " 3: Permission denied, Content Authorization missing
" 4: Store not existing
" 8: Error
rc_text = rc_text.
LOOP AT lt_snapshot INTO DATA(lt_snapshot_elem).
READ TABLE lt_snapshot_elem INTO DATA(ls_component) INDEX 1.
CHECK ls_component-fieldname = 'COMPONENT'.
CHECK ls_component-fieldvalue = 'SAP_BASIS'.
READ TABLE lt_snapshot_elem INTO DATA(ls_release) INDEX 2.
CHECK ls_release-fieldname = 'RELEASE'.
ls_result-abap_release = ls_release-fieldvalue.
READ TABLE lt_snapshot_elem INTO DATA(ls_extrelease) INDEX 3.
CHECK ls_extrelease-fieldname = 'EXTRELEASE'.
ls_result-abap_sp = ls_extrelease-fieldvalue.
ENDLOOP.
IF tabix > 0.
MODIFY lt_result FROM ls_result INDEX tabix.
ELSE.
APPEND ls_result TO lt_result.
ENDIF.
ENDLOOP. " lt_STORE_DIR
ENDMETHOD. " get_ABAP_COMP_SPLEVEL
METHOD get_abap_notes.
CHECK p_abap = 'X'.
DATA:
lt_store_dir_tech TYPE tt_diagst_store_dir_tech,
lt_store_dir TYPE tt_diagst_store_dir,
lt_fieldlist TYPE tt_diagst_table_store_fields,
lt_snapshot TYPE tt_diagst_trows,
rc TYPE i,
rc_text TYPE natxt.
DATA tabix TYPE i.
" Maybe it' faster to call it twice including a SEARCH_STRING for both note numbers.
CALL FUNCTION 'DIAGST_GET_STORES'
EXPORTING
" The "System Filter" parameters allow to get all Stores of a system or technical system.
" Some combinations of the four parameters are not allowed.
" The function will return an error code in such a case.
* SID = ' '
* INSTALL_NUMBER = ' '
* LONG_SID = ' '
* TECH_SYSTEM_TYPE = 'ABAP' "(only together with LONG_SID)
" Store key fields
group_namespace = 'ACTIVE' "(optional)
group_landscape_class = 'CL_DIAGLS_ABAP_TECH_SYST' "(optional)
* GROUP_LANDSCAPE_ID = ' '
* GROUP_COMP_ID = ' '
group_source = 'ABAP' "(optional)
group_name = 'ABAP-SOFTWARE' "(optional)
store_category = 'SOFTWARE' "(optional)
store_type = 'TABLE' "(optional)
* STORE_FULLPATH = ' '
store_name = 'ABAP_NOTES'
" Special filters
store_mainalias = 'ABAP-SOFTWARE' "(optional)
store_subalias = 'ABAP-NOTES' "(optional)
* STORE_TPL_ID = ' '
* HAS_ELEMENT_FROM = " date range
* HAS_ELEMENT_TO = " date range
* ELEMENT_FILTER = 'C' " (C)hange, (I)nitial, (A)ll
* CASE_INSENSITIVE = ' '
* PATTERN_SEARCH = 'X' " Allow pattern search for SEARCH_STRING
* SEARCH_STRING =
* ONLY_RELEVANT = 'X'
* PROTECTED = 'A' " (N)ot, (Y)es, (A)ll
" Others
* DISPLAY = ' ' " Only useful if the function is manually executed by transaction SE37.
" Setting this parameter to 'X' will display the result.
* CALLING_APPL = ' '
IMPORTING
* STORE_DIR_TECH = lt_STORE_DIR_TECH "(efficient, reduced structure)
store_dir = lt_store_dir "(not recommended anymore)
* STORE_DIR_MI = "(SAP internal usage only)
* STORE_STATS = " History regarding the changes of elements (configuration items).
* PARAMETER = "(SAP internal usage only)
rc = rc
rc_text = rc_text.
IF rc IS NOT INITIAL.
MESSAGE e001(00) WITH rc_text ##MG_MISSING.
ENDIF.
LOOP AT lt_store_dir INTO DATA(ls_store_dir)
WHERE long_sid IN p_sid
AND store_main_state_type IN p_state
.
" Do we already have an entry for this system?
READ TABLE lt_result INTO DATA(ls_result)
WITH KEY
install_number = ls_store_dir-install_number
long_sid = ls_store_dir-long_sid
sid = ls_store_dir-sid
.
IF sy-subrc = 0.
tabix = sy-tabix.
ELSE.
tabix = -1.
CLEAR ls_result.
MOVE-CORRESPONDING ls_store_dir TO ls_result.
ENDIF.
CALL FUNCTION 'DIAGST_TABLE_SNAPSHOT'
EXPORTING
store_id = ls_store_dir-store_id
* TIMESTAMP = " if not specified the latest available snapshot is returned
* CALLING_APPL = ' '
IMPORTING
fieldlist = lt_fieldlist
* SNAPSHOT_VALID_FROM =
* SNAPSHOT_VALID_TO_CONFIRMED =
* SNAPSHOT_VALID_TO =
snapshot = lt_snapshot " The content of the requested snapshot in ABAP DDIC type format
* SNAPSHOT_TR =
* SNAPSHOT_ITSAM = " The content of the requested snapshot in XML-based format
rc = rc " 3: Permission denied, Content Authorization missing
" 4: Store not existing
" 8: Error
rc_text = rc_text.
LOOP AT lt_snapshot INTO DATA(lt_snapshot_elem).
READ TABLE lt_snapshot_elem INTO DATA(ls_note) INDEX 1. "
CHECK ls_note-fieldname = 'NOTE'.
CHECK ls_note-fieldvalue = '0003089413'
OR ls_note-fieldvalue = '0003287611'
OR ls_note-fieldvalue = '0003304520'
.
READ TABLE lt_snapshot_elem INTO DATA(ls_version) INDEX 2. "
CHECK ls_version-fieldname = 'VERSION'.
"READ TABLE lt_snapshot_elem INTO data(ls_TEXT) INDEX 3. "
"check ls_TEXT-fieldname = 'TEXT'.
READ TABLE lt_snapshot_elem INTO DATA(ls_prstatust) INDEX 4. "
CHECK ls_prstatust-fieldname = 'PRSTATUST'.
READ TABLE lt_snapshot_elem INTO DATA(ls_prstatus) INDEX 5. "
CHECK ls_prstatus-fieldname = 'PRSTATUS'.
DATA(status) = ls_prstatust-fieldvalue && ` version ` && ls_version-fieldvalue.
CASE ls_note-fieldvalue.
WHEN '0003089413'.
ls_result-note_3089413 = status.
ls_result-note_3089413_prstatus = ls_prstatus-fieldvalue.
WHEN '0003287611'.
ls_result-note_3287611 = status.
ls_result-note_3287611_prstatus = ls_prstatus-fieldvalue.
WHEN '0003304520'.
ls_result-note_3304520 = status.
ls_result-note_3304520_prstatus = ls_prstatus-fieldvalue.
ENDCASE.
ENDLOOP.
IF tabix > 0.
MODIFY lt_result FROM ls_result INDEX tabix.
ELSE.
APPEND ls_result TO lt_result.