Skip to content

Commit 5502440

Browse files
Move DB accesses from constructor to runtime (#634)
DB accesses in constructors are discouraged by the ATC framework and can lead to problems in upgrade shadow systems. This moves the check for a profile for the current user from the constructor to QUERY_ATTRIBUTES. This means the checks no longer display as having no settings in SCI when a profile is active for the current user, but instead show a corresponding message when the settings button is clicked.
1 parent b13726a commit 5502440

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/foundation/y_check_base.clas.abap

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
120120
RAISING cx_sy_range_out_of_bounds.
121121

122122
PRIVATE SECTION.
123-
METHODS do_attributes_exist RETURNING VALUE(result) TYPE abap_bool.
123+
METHODS profile_is_active_for_user RETURNING VALUE(result) TYPE abap_bool.
124124

125125
METHODS instantiate_objects.
126126

@@ -172,7 +172,8 @@ CLASS Y_CHECK_BASE IMPLEMENTATION.
172172
settings-documentation = |{ c_docs_path-main }check_documentation.md|.
173173
settings-ignore_pseudo_comments = abap_false.
174174

175-
has_attributes = do_attributes_exist( ).
175+
has_attributes = abap_true.
176+
attributes_ok = abap_true.
176177

177178
relevant_statement_types = VALUE #( ( scan_struc_stmnt_type-form )
178179
( scan_struc_stmnt_type-method )
@@ -244,14 +245,13 @@ CLASS Y_CHECK_BASE IMPLEMENTATION.
244245
ENDMETHOD.
245246

246247

247-
METHOD do_attributes_exist.
248+
METHOD profile_is_active_for_user.
248249
TRY.
249250
DATA(profiles) = y_profile_manager=>create( )->select_profiles( sy-uname ).
250-
attributes_ok = xsdbool( profiles IS INITIAL ).
251+
result = xsdbool( profiles IS NOT INITIAL ).
251252
CATCH ycx_entry_not_found.
252-
attributes_ok = abap_true.
253+
result = abap_true.
253254
ENDTRY.
254-
result = attributes_ok.
255255
ENDMETHOD.
256256

257257

@@ -356,6 +356,11 @@ CLASS Y_CHECK_BASE IMPLEMENTATION.
356356
DATA sci_attributes TYPE sci_atttab.
357357
DATA message(72) TYPE c.
358358

359+
if profile_is_active_for_user( ).
360+
message 'Settings cannot be maintained while a profile is active for the current user'(prf) type 'I'.
361+
return.
362+
endif.
363+
359364
READ TABLE check_configurations INTO DATA(check_configuration) INDEX 1.
360365
IF sy-subrc <> 0 AND use_default_attributes = abap_true.
361366
check_configuration-object_creation_date = settings-object_created_on.
@@ -535,7 +540,7 @@ CLASS Y_CHECK_BASE IMPLEMENTATION.
535540
ENDIF.
536541

537542
" Profile
538-
IF has_attributes = abap_false.
543+
IF profile_is_active_for_user( ).
539544
TRY.
540545
check_configurations = clean_code_manager->read_check_customizing( myname ).
541546
CATCH ycx_no_check_customizing.

0 commit comments

Comments
 (0)