-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathzcheck_note_3089413_frun.prog.abap
3179 lines (2621 loc) · 126 KB
/
zcheck_note_3089413_frun.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_FRUN
*& 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
*&
*& 10.07.2023 Updated Kernel prerequisites as described in note 3224161
*& Updated Note prerequisites for note 3287611 v9
*& 13.03.2023 Updated note 3287611, new note 3304520
*& 27.02.2023 Initial version based on the similar report for the SAP Solution Manager
*& No API is not used but direct DB access,therefore further changes are recommended
*& Reason: Function CCDB_GET_STORES work for a single system name only
*&---------------------------------------------------------------------*
REPORT zcheck_note_3089413_frun.
CONSTANTS c_program_version(30) TYPE c VALUE '10.07.2023 FQ4'.
TYPE-POOLS: icon, col, sym.
* System name
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) ss_sid FOR FIELD p_EXTSID.
SELECT-OPTIONS p_EXTSID FOR ('LMDB_ESID'). " Extended System ID
SELECTION-SCREEN END OF LINE.
* Check Kernel
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_kern AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(33) 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(33) 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(33) 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(33) 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.
* Store status
"SELECTION-SCREEN BEGIN OF LINE.
"SELECTION-SCREEN COMMENT 1(30) ss_state FOR FIELD p_state.
"SELECT-OPTIONS p_state FOR sel_store_dir-store_main_state_type." 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,
" Key
extsid TYPE lmdb_esid, " from CCDB_ISCI-EXTSID,
sid TYPE lmdb_esid,
install_number TYPE lmdb_installation_no,
" 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
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: we show the status of the first found store only which is usually store SAP_KERNEL
store_name TYPE ccdb_store-store_name,
store_id TYPE ccdb_store-store_id,
store_to_date TYPE ccdb_store-store_to_date,
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,
extsid TYPE lmdb_esid,
sid TYPE diagls_technical_system_sid, "sdiagst_store_dir-sid,
install_number TYPE diagls_tech_syst_install_nbr,
destination_data TYPE tt_destination_data,
END OF ts_destination,
tt_destinations TYPE STANDARD TABLE OF ts_destination WITH KEY sid install_number,
" Mapping between extended SID and SID with installation number
BEGIN OF ts_EXTSID_data,
extsid TYPE lmdb_esid,
rt_cim_guid TYPE cof_rt_tree_p-rt_cim_guid,
hier_id TYPE cof_rt_tree_p-hier_id,
"system_type TYPE lmdb_system_type,
sid TYPE lmdb_esid,
install_number TYPE lmdb_installation_no,
END OF ts_EXTSID_data,
tt_EXTSID_DATA TYPE STANDARD TABLE OF ts_EXTSID_data WITH KEY extsid.
*---------------------------------------------------------------------*
* CLASS lcl_report DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_report DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
initialization,
f4_EXTSID,
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,
" Mapping between extended SID and SID with installation number
lt_EXTSID_data TYPE tt_EXTSID_data.
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_EXTSID_data,
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,
validate_kernel,
validate_abap,
validate_mutual_trust,
count_dest_per_trust,
validate_trust_for_dest,
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
extsid TYPE ts_result-extsid
rfctrustsy TYPE ts_result-sid
llicense_nr TYPE ts_result-install_number,
show_destinations
IMPORTING
column TYPE salv_de_column
extsid TYPE ts_result-extsid
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'.
ps_dest = 'Check Trusted Destinations'.
ps_lout = 'Layout'.
CONCATENATE 'Program version:'(ver) c_program_version INTO ss_vers
SEPARATED BY space.
ENDMETHOD. " initialization
METHOD f4_EXTSID.
TYPES:
BEGIN OF ts_f4_value,
extsid TYPE ccdb_isci-extsid,
END OF ts_f4_value.
DATA:
f4_value TYPE ts_f4_value,
f4_value_tab TYPE TABLE OF ts_f4_value.
DATA:
rc TYPE i,
rc_text TYPE natxt.
SELECT DISTINCT extsid FROM ccdb_isci INTO TABLE f4_value_tab
ORDER BY extsid.
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 = 'EXTSID'
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_EXTSID
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_EXTSID_data( ). " Mapping between extended SID and SID with installation number
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
validate_kernel( ).
validate_abap( ).
count_dest_per_trust( ).
validate_trust_for_dest( ).
validate_mutual_trust( ).
show_result( ).
ENDMETHOD. " start_of_selection
METHOD get_EXTSID_data.
" Option 1: Class cl_lmdb_filterbar_dpc_util->get_technical_Systems()
" Option 2: Table COF_RT_TREE_P (only usable for CSA data)
DATA ls_extsid_data TYPE ts_extsid_data.
" Get GUID and HIER_ID of ABAP systems
SELECT
rt_cim_guid,
hier_id
FROM cof_rt_tree_p
INTO TABLE @DATA(lt_GUIDs)
WHERE name = 'SYSTEM_TYPE'
AND value = 'ABAP'.
" Get data
SELECT *
FROM cof_rt_tree_p
INTO @DATA(ls_cof_rt_tree_p)
FOR ALL ENTRIES IN @lt_GUIDs
WHERE rt_cim_guid = @lt_GUIDs-rt_cim_guid
AND hier_id = @lt_GUIDs-hier_id
AND ( name = 'ESID'
OR name = 'TS_INSTALL_NUMBER'
OR name = 'TS_SID' )
ORDER BY PRIMARY KEY. " Important to the the correct order of CASE events per system
CASE ls_cof_rt_tree_p-name.
WHEN 'ESID'.
CLEAR ls_extsid_data.
ls_extsid_data-extsid = ls_cof_rt_tree_p-value.
ls_extsid_data-rt_cim_guid = ls_cof_rt_tree_p-rt_cim_guid.
ls_extsid_data-hier_id = ls_cof_rt_tree_p-hier_id.
WHEN 'TS_INSTALL_NUMBER'.
ls_extsid_data-install_number = ls_cof_rt_tree_p-value.
WHEN 'TS_SID'.
ls_extsid_data-sid = ls_cof_rt_tree_p-value.
APPEND ls_extsid_data TO lt_extsid_data.
ENDCASE.
ENDSELECT.
SORT lt_extsid_data BY extsid.
ENDMETHOD. " get_EXTSID_data
METHOD get_sap_kernel.
CHECK p_kern = 'X'.
DATA tabix TYPE sy-tabix.
" Get stores
" Function CCDB_GET_STORES work for a single system name only
* CALL FUNCTION 'CCDB_GET_STORES'
* EXPORTING
** RT_CIM_GUID =
** RT_CIM_NSPA =
** EXTSID IN @p_extsid " System name
* SYSTEM_TYPE = 'ABAP' " System type
** STORE_CIM_GUID =
* SCI_ID = 'S00001' " Store id
** STORE_NAME_EXT = '*'
* STORE_NAME = 'SAP_KERNEL' " Store name
** CALLER =
** DISPLAY =
** IMPORTING
** CCDB_DIRV = " Store directory
** CCDB_DIRV_ATTR = " Attribute host name
** CCDB_DIRV_CXML =
** CCDB_DIRV_ATTR_CXML =
** RC =
** RC_STRING =
* .
SELECT *
FROM ccdb_rt_dirv_dbv " CCDB: Root object - Directory
INTO TABLE @DATA(lt_storetab)
WHERE rt_type = 'TS' " Root Type
AND extsid IN @p_extsid " System name
AND system_type = 'ABAP' " System type
AND sci_id = 'S00001' " Store id
AND store_name = 'SAP_KERNEL' " Store name
ORDER BY extsid .
CHECK sy-subrc IS INITIAL.
" Use table name from first store
READ TABLE lt_storetab INTO DATA(ls_storetab) INDEX 1.
CHECK sy-subrc IS INITIAL.
" Create data table
DATA(ddic_tablename) = ls_storetab-ddic_tablename.
DATA ref_tab TYPE REF TO data.
CREATE DATA ref_tab TYPE STANDARD TABLE OF (ddic_tablename).
FIELD-SYMBOLS <fs_table> TYPE ANY TABLE.
ASSIGN ref_tab->* TO <fs_table>.
LOOP AT lt_storetab INTO ls_storetab
WHERE ddic_tablename = ddic_tablename.
" Do we already have an entry for this system?
READ TABLE lt_result INTO DATA(ls_result)
WITH KEY
extsid = ls_storetab-extsid.
IF sy-subrc = 0.
tabix = sy-tabix.
"MOVE-CORRESPONDING ls_storetab TO ls_result.
ELSE.
tabix = -1.
CLEAR ls_result.
MOVE-CORRESPONDING ls_storetab TO ls_result. " EXTSID, STORE_NAME, STORE_ID, STORE_TO_DATE
READ TABLE lt_extsid_data INTO DATA(ls_extsid_data)
WITH TABLE KEY
extsid = ls_storetab-extsid.
IF sy-subrc = 0.
ls_result-sid = ls_extsid_data-sid.
ls_result-install_number = ls_extsid_data-install_number.
ENDIF.
ENDIF.
" Get data
SELECT *
FROM (ddic_tablename) " CCDB_DATA_001
WHERE cd_store_id = @ls_storetab-store_id
and CD_HIST_DATE_TO is initial " ignore old change documents
ORDER BY PRIMARY KEY
INTO TABLE @<fs_table>.
LOOP AT <fs_table> ASSIGNING FIELD-SYMBOL(<entry>).
" Table CCDB_DATA_001
ASSIGN COMPONENT 'NAME' OF STRUCTURE <entry> TO FIELD-SYMBOL(<name>).
ASSIGN COMPONENT 'VALUE' OF STRUCTURE <entry> TO FIELD-SYMBOL(<value>).
" Copy data
CASE <name>.
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 = <value>.
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 = <value>.
WHEN 'KERN_REL'. " 722_EXT_REL
ls_result-kern_rel = <value>.
WHEN 'PLATFORM-ID'. " 390
" not used yet
ENDCASE.
ENDLOOP. " <fs_table>
IF tabix > 0.
MODIFY lt_result FROM ls_result INDEX tabix.
ELSE.
APPEND ls_result TO lt_result.
ENDIF.
ENDLOOP. " lt_storetab
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 tabix TYPE i.
" Get stores
SELECT *
FROM ccdb_rt_dirv_dbv " CCDB: Root object - Directory
INTO TABLE @DATA(lt_storetab)
WHERE rt_type = 'TS' " Root Type
AND extsid IN @p_extsid " System name
AND system_type = 'ABAP' " System type
AND sci_id = 'S00120' " Store id
AND store_name = 'COMP_LEVEL' " Store name
ORDER BY extsid .
CHECK sy-subrc IS INITIAL.
" Use table name from first store
READ TABLE lt_storetab INTO DATA(ls_storetab) INDEX 1.
CHECK sy-subrc IS INITIAL.
" Create data table
DATA(ddic_tablename) = ls_storetab-ddic_tablename.
DATA ref_tab TYPE REF TO data.
CREATE DATA ref_tab TYPE STANDARD TABLE OF (ddic_tablename).
FIELD-SYMBOLS <fs_table> TYPE ANY TABLE.
ASSIGN ref_tab->* TO <fs_table>.
LOOP AT lt_storetab INTO ls_storetab
WHERE ddic_tablename = ddic_tablename.
" Do we already have an entry for this system?
READ TABLE lt_result INTO DATA(ls_result)
WITH KEY
extsid = ls_storetab-extsid.
IF sy-subrc = 0.
tabix = sy-tabix.
"MOVE-CORRESPONDING ls_storetab TO ls_result.
ELSE.
tabix = -1.
CLEAR ls_result.
MOVE-CORRESPONDING ls_storetab TO ls_result. " EXTSID, STORE_NAME, STORE_ID, STORE_TO_DATE
READ TABLE lt_extsid_data INTO DATA(ls_extsid_data)
WITH TABLE KEY
extsid = ls_storetab-extsid.
IF sy-subrc = 0.
ls_result-sid = ls_extsid_data-sid.
ls_result-install_number = ls_extsid_data-install_number.
ENDIF.
ENDIF.
" Get data
SELECT *
FROM (ddic_tablename) " CCDB_DATA_110
WHERE cd_store_id = @ls_storetab-store_id
and CD_HIST_DATE_TO is initial " ignore old change documents
AND component = 'SAP_BASIS'
ORDER BY PRIMARY KEY
INTO TABLE @<fs_table>.
LOOP AT <fs_table> ASSIGNING FIELD-SYMBOL(<entry>).
" Table CCDB_DATA_110
ASSIGN COMPONENT 'COMPONENT' OF STRUCTURE <entry> TO FIELD-SYMBOL(<component>).
ASSIGN COMPONENT 'VERSION' OF STRUCTURE <entry> TO FIELD-SYMBOL(<release>).
ASSIGN COMPONENT 'SP' OF STRUCTURE <entry> TO FIELD-SYMBOL(<sp>).
" Copy data
ls_result-abap_release = <release>.
ls_result-abap_sp = <sp>.
ENDLOOP. " <fs_table>
IF tabix > 0.
MODIFY lt_result FROM ls_result INDEX tabix.
ELSE.
APPEND ls_result TO lt_result.
ENDIF.
ENDLOOP. " lt_storetab
ENDMETHOD. " get_ABAP_COMP_SPLEVEL
METHOD get_abap_notes.
CHECK p_abap = 'X'.
DATA tabix TYPE i.
" Get stores
SELECT *
FROM ccdb_rt_dirv_dbv " CCDB: Root object - Directory
INTO TABLE @DATA(lt_storetab)
WHERE rt_type = 'TS' " Root Type
AND extsid IN @p_extsid " System name
AND system_type = 'ABAP' " System type
AND sci_id = 'S00028' " Store id
AND store_name = 'ABAP_NOTES' " Store name
ORDER BY extsid .
CHECK sy-subrc IS INITIAL.
" Use table name from first store
READ TABLE lt_storetab INTO DATA(ls_storetab) INDEX 1.
CHECK sy-subrc IS INITIAL.
" Create data table
DATA(ddic_tablename) = ls_storetab-ddic_tablename.
DATA ref_tab TYPE REF TO data.
CREATE DATA ref_tab TYPE STANDARD TABLE OF (ddic_tablename).
FIELD-SYMBOLS <fs_table> TYPE ANY TABLE.
ASSIGN ref_tab->* TO <fs_table>.
LOOP AT lt_storetab INTO ls_storetab
WHERE ddic_tablename = ddic_tablename.
" Do we already have an entry for this system?
READ TABLE lt_result INTO DATA(ls_result)
WITH KEY
extsid = ls_storetab-extsid.
IF sy-subrc = 0.
tabix = sy-tabix.
"MOVE-CORRESPONDING ls_storetab TO ls_result.
ELSE.
tabix = -1.
CLEAR ls_result.
MOVE-CORRESPONDING ls_storetab TO ls_result. " EXTSID, STORE_NAME, STORE_ID, STORE_TO_DATE
READ TABLE lt_extsid_data INTO DATA(ls_extsid_data)
WITH TABLE KEY
extsid = ls_storetab-extsid.
IF sy-subrc = 0.
ls_result-sid = ls_extsid_data-sid.
ls_result-install_number = ls_extsid_data-install_number.
ENDIF.
ENDIF.
" Get data
SELECT *
FROM (ddic_tablename) " CCDB_DATA_112
WHERE cd_store_id = @ls_storetab-store_id
and CD_HIST_DATE_TO is initial " ignore old change documents
AND ( note = '0003089413'
OR note = '0003287611'
OR note = '0003304520' )
ORDER BY PRIMARY KEY
INTO TABLE @<fs_table>.
LOOP AT <fs_table> ASSIGNING FIELD-SYMBOL(<entry>).
" Table CCDB_DATA_112
ASSIGN COMPONENT 'NOTE' OF STRUCTURE <entry> TO FIELD-SYMBOL(<note>).
ASSIGN COMPONENT 'VERSION' OF STRUCTURE <entry> TO FIELD-SYMBOL(<version>).
ASSIGN COMPONENT 'TEXT' OF STRUCTURE <entry> TO FIELD-SYMBOL(<text>).
ASSIGN COMPONENT 'PRSTATUS' OF STRUCTURE <entry> TO FIELD-SYMBOL(<prstatus>).
ASSIGN COMPONENT 'PRSTATUST' OF STRUCTURE <entry> TO FIELD-SYMBOL(<prstatust>).
" Copy data
DATA(status) = <prstatust> && ` version ` && <version>.
CASE <note>.
WHEN '0003089413'.
ls_result-note_3089413 = status.
ls_result-note_3089413_prstatus = <prstatus>.
WHEN '0003287611'.
ls_result-note_3287611 = status.
ls_result-note_3287611_prstatus = <prstatus>.
WHEN '0003304520'.
ls_result-note_3304520 = status.
ls_result-note_3304520_prstatus = <prstatus>.
ENDCASE.
ENDLOOP. " <fs_table>
IF tabix > 0.
MODIFY lt_result FROM ls_result INDEX tabix.
ELSE.
APPEND ls_result TO lt_result.
ENDIF.
ENDLOOP. " lt_storetab
ENDMETHOD. " get_ABAP_NOTES
METHOD get_rfcsysacl.
CHECK p_trust = 'X'.
DATA tabix TYPE i.
" Get stores
SELECT *
FROM ccdb_rt_dirv_dbv " CCDB: Root object - Directory
INTO TABLE @DATA(lt_storetab)
WHERE rt_type = 'TS' " Root Type
AND extsid IN @p_extsid " System name
AND system_type = 'ABAP' " System type
AND sci_id = 'S00048' " Store id
AND store_name = 'RFCSYSACL' " Store name
ORDER BY extsid .
CHECK sy-subrc IS INITIAL.
" Use table name from first store
READ TABLE lt_storetab INTO DATA(ls_storetab) INDEX 1.
CHECK sy-subrc IS INITIAL.
" Create data table
DATA(ddic_tablename) = ls_storetab-ddic_tablename.
DATA ref_tab TYPE REF TO data.
CREATE DATA ref_tab TYPE STANDARD TABLE OF (ddic_tablename).
FIELD-SYMBOLS <fs_table> TYPE ANY TABLE.
ASSIGN ref_tab->* TO <fs_table>.
LOOP AT lt_storetab INTO ls_storetab
WHERE ddic_tablename = ddic_tablename.
" Do we already have an entry for this system?
READ TABLE lt_result INTO DATA(ls_result)
WITH KEY
extsid = ls_storetab-extsid.
IF sy-subrc = 0.
tabix = sy-tabix.
"MOVE-CORRESPONDING ls_storetab TO ls_result.
ELSE.
tabix = -1.
CLEAR ls_result.
MOVE-CORRESPONDING ls_storetab TO ls_result. " EXTSID, STORE_NAME, STORE_ID, STORE_TO_DATE
READ TABLE lt_extsid_data INTO DATA(ls_extsid_data)
WITH TABLE KEY
extsid = ls_storetab-extsid.
IF sy-subrc = 0.
ls_result-sid = ls_extsid_data-sid.
ls_result-install_number = ls_extsid_data-install_number.
ENDIF.
ENDIF.
" Get data
SELECT *
FROM (ddic_tablename) " CCDB_DATA_127
WHERE cd_store_id = @ls_storetab-store_id
and CD_HIST_DATE_TO is initial " ignore old change documents
ORDER BY PRIMARY KEY
INTO TABLE @<fs_table>.
DATA ls_trusted_system TYPE ts_trusted_system.
CLEAR ls_trusted_system.
LOOP AT <fs_table> ASSIGNING FIELD-SYMBOL(<entry>).
" Table CCDB_DATA_127
ASSIGN COMPONENT 'RFCSYSID' OF STRUCTURE <entry> TO FIELD-SYMBOL(<rfcsysid>).
ASSIGN COMPONENT 'TLICENSE_NR' OF STRUCTURE <entry> TO FIELD-SYMBOL(<tlicense_nr>).
ASSIGN COMPONENT 'RFCTRUSTSY' OF STRUCTURE <entry> TO FIELD-SYMBOL(<rfctrustsy>).
ASSIGN COMPONENT 'RFCDEST' OF STRUCTURE <entry> TO FIELD-SYMBOL(<rfcdest>).
ASSIGN COMPONENT 'RFCTCDCHK' OF STRUCTURE <entry> TO FIELD-SYMBOL(<rfctcdchk>).
ASSIGN COMPONENT 'RFCSNC' OF STRUCTURE <entry> TO FIELD-SYMBOL(<rfcsnc>).
ASSIGN COMPONENT 'RFCSLOPT' OF STRUCTURE <entry> TO FIELD-SYMBOL(<rfcslopt>).
ASSIGN COMPONENT 'RFCCREDEST' OF STRUCTURE <entry> TO FIELD-SYMBOL(<rfccredest>).
ASSIGN COMPONENT 'RFCREGDEST' OF STRUCTURE <entry> TO FIELD-SYMBOL(<rfcregdest>).
ASSIGN COMPONENT 'LLICENSE_NR' OF STRUCTURE <entry> TO FIELD-SYMBOL(<llicense_nr>).
ASSIGN COMPONENT 'RFCSECKEY' OF STRUCTURE <entry> TO FIELD-SYMBOL(<rfcseckey>).
" Copy data
" Store RRFCSYSACL data
if ls_trusted_system-rfctrustsy is initial.
ls_trusted_system-rfctrustsy = <rfctrustsy>.
ls_trusted_system-llicense_nr = <llicense_nr>.
" Add installation number
IF ls_trusted_system-llicense_nr IS INITIAL.
ls_trusted_system-llicense_nr = ls_result-install_number.
ENDIF.
endif.
" Store RRFCSYSACL data
DATA ls_rfcsysacl_data TYPE ts_rfcsysacl_data.
CLEAR ls_rfcsysacl_data.
ls_rfcsysacl_data-rfcsysid = <rfcsysid>.
ls_rfcsysacl_data-tlicense_nr = <tlicense_nr>.
ls_rfcsysacl_data-rfctrustsy = <rfctrustsy>.
ls_rfcsysacl_data-rfcdest = <rfcdest>.
ls_rfcsysacl_data-rfctcdchk = <rfctcdchk>.
ls_rfcsysacl_data-rfcsnc = <rfcsnc>.
ls_rfcsysacl_data-rfcslopt = <rfcslopt>.
" only available in higher versions
ls_rfcsysacl_data-rfccredest = <rfccredest>.
ls_rfcsysacl_data-rfcregdest = <rfcregdest>.
ls_rfcsysacl_data-llicense_nr = <llicense_nr>.
ls_rfcsysacl_data-rfcseckey = <rfcseckey>.
" Add installation number
IF ls_rfcsysacl_data-llicense_nr IS INITIAL.
ls_rfcsysacl_data-llicense_nr = ls_result-install_number.
ENDIF.
" Store RRFCSYSACL data
APPEND ls_rfcsysacl_data TO ls_trusted_system-rfcsysacl_data.
ADD 1 TO ls_result-trustsy_cnt_all.
IF ls_rfcsysacl_data-rfctcdchk IS NOT INITIAL.
ADD 1 TO ls_result-trustsy_cnt_tcd.
ENDIF.
" Get version
DATA version(1).
version = ls_rfcsysacl_data-rfcslopt. " get first char of the string
CASE version.
WHEN '3'. ADD 1 TO ls_result-trustsy_cnt_3.
WHEN '2'. ADD 1 TO ls_result-trustsy_cnt_2.
WHEN ' '. ADD 1 TO ls_result-trustsy_cnt_1.
ENDCASE.
" Identify selftrust
IF ls_rfcsysacl_data-rfcsysid = ls_rfcsysacl_data-rfctrustsy.
IF ls_rfcsysacl_data-llicense_nr IS NOT INITIAL AND ls_rfcsysacl_data-llicense_nr = ls_rfcsysacl_data-tlicense_nr.
ls_result-explicit_selftrust = 'Explicit selftrust'.
ELSE.
ls_result-explicit_selftrust = 'explicit selftrust'. " no check for installation number
ENDIF.
ENDIF.
ENDLOOP. " <fs_table>
" Store trusted systems
APPEND ls_trusted_system TO lt_trusted_systems.
IF tabix > 0.
MODIFY lt_result FROM ls_result INDEX tabix.
ELSE.
APPEND ls_result TO lt_result.
ENDIF.
ENDLOOP. " lt_storetab