ENHANCEMENT 1 ZS_ATC_FILTER_FINDINGS. "active version
zcl_s_atc_filter_findings=>filter( exporting i_or_inspection = anonymous_inspection
changing c_it_findings = findings ).
CLASS zcl_s_atc_filter_findings DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
CLASS-METHODS:
filter
IMPORTING i_or_inspection TYPE REF TO cl_ci_inspection
CHANGING c_it_findings TYPE scit_rest.
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-METHODS:
is_finding_new
IMPORTING i_wa_f TYPE scir_rest
RETURNING VALUE(r_result) TYPE abap_bool
RAISING cx_satc_failure,
init_comparison_data
IMPORTING i_it_findings TYPE scit_rest
RAISING cx_satc_failure,
get_consolidated_names
IMPORTING i_it_findings TYPE scit_rest
RETURNING VALUE(r) TYPE if_satc_result_access_filter=>ty_object_names,
filter_previous_findings
CHANGING c_it_findings TYPE scit_rest
RAISING x_satc_failure.
CLASS-DATA s_comparison_findings TYPE scit_rest.
ENDCLASS.
In the filter() method, I check the variant name. For Z_DELTA, I forward to method filter_previous_findings() to do the actual work.
METHOD filter.
CHECK c_it_findings IS NOT INITIAL.
TRY.
IF i_or_inspection->chkv->chkvinf-checkvname = 'Z_DELTA'.
filter_previous_findings( CHANGING c_it_findings = c_it_findings ).
ENDIF.
CATCH cx_satc_failure INTO DATA(cx).
DATA(exc_text) = cx->get_text( ).
MESSAGE exc_text TYPE 'E'.
ENDTRY.
METHOD filter_previous_findings.
init_comparison_data( i_it_findings = c_it_findings ).
LOOP AT c_it_findings ASSIGNING FIELD-SYMBOL(<f>).
IF NOT is_finding_new( <f> ).
DELETE c_it_findings USING KEY loop_key.
ENDIF.
ENDLOOP.
METHOD init_comparison_data.
DATA(object_names) = get_consolidated_names( i_it_findings ).
CHECK object_names IS NOT INITIAL.
DATA(or_factory) = NEW cl_satc_api_factory( ).
DATA(or_filter) = or_factory->create_result_access_filter( i_object_names = object_names ).
SELECT display_id FROM satc_ac_resulth
WHERE is_central_run = 'X'
AND is_complete = 'X'
AND title LIKE 'D1Q:%' " adapt this to the pattern of your mass test run name
ORDER BY scheduled_on_ts DESCENDING
INTO @DATA(display_id)
UP TO 1 ROWS.
ENDSELECT.
CHECK sy-subrc = 0.
or_factory->create_result_access( i_result_id = display_id )->get_findings(
EXPORTING i_filter = or_filter
IMPORTING e_findings = s_comparison_findings ).
ENDMETHOD.
In the above method, we do not want to load all findings of the mass run (usually an enormously big number, depending on your system), so we prepare a filter from the objects in the current findings, using method get_consolidated_names().
METHOD get_consolidated_names.
DATA wa LIKE LINE OF r.
wa = VALUE #( sign = 'I' option = 'EQ' ).
LOOP AT i_it_findings ASSIGNING FIELD-SYMBOL(<f>).
wa-low = <f>-objname.
APPEND wa TO r.
ENDLOOP.
SORT r.
DELETE ADJACENT DUPLICATES FROM r.
And here is the method for the actual comparison:
METHOD is_finding_new.
READ TABLE s_comparison_findings WITH KEY test = i_wa_f-test " test class
code = i_wa_f-code
objtype = i_wa_f-objtype
objname = i_wa_f-objname
" sub object (where the findings was actually detected)
sobjtype = i_wa_f-sobjtype
sobjname = i_wa_f-sobjname
param1 = i_wa_f-param1
" param2 seems to contain technical and sometimes
" language-dependent info, so we ignore it
TRANSPORTING NO FIELDS.
r_result = xsdbool( sy-subrc <> 0 ).
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |