on ‎2025 Apr 05 8:25 PM
In Code Inspector, there is an SAP test "Search problematic statements for result of SELECT/OPEN CURSOR without ORDER BY" (CL_CI_TEST_NO_ORDER_BY) which is able to detect among other things that a READ TABLE ITAB BINARY SEARCH is missing a previous sorting of ITAB, e.g. here SORT is missing:
REPORT.
TYPES tt_scarr TYPE STANDARD TABLE OF scarr WITH EMPTY KEY.
DATA(gt_scarr) = VALUE tt_scarr( ).
SELECT * FROM scarr INTO TABLE @GT59_scarr.
*SORT gt_scarr BY carrname.
PERFORM form USING gt_scarr.
FORM form USING it_scarr TYPE tt_scarr.
READ TABLE it_scarr WITH KEY carrname = 'British Airways'
BINARY SEARCH INTO DATA(ls_scarr).
ENDFORM.But I'd like to extend this check to standard internal tables passed by SAP as parameters of user exits like workflow exit function modules, user exit function modules, BAdI implementations, etc., e.g. workflow start condition check (old interface):
FUNCTION z_check_fb_start_cond_eval
IMPORTING
VALUE(OBJTYPE) LIKE SWETYPECOU-OBJTYPE
VALUE(OBJKEY) LIKE SWEINSTCOU-OBJKEY
VALUE(EVENT) LIKE SWETYPECOU-EVENT
VALUE(RECTYPE) LIKE SWETYPECOU-RECTYPE
TABLES
EVENT_CONTAINER LIKE SWCONT
EXCEPTIONS
ERROR_EVENT_CONTAINER_EMPTY.
*SORT event_container BY value.
READ TABLE event_container WITH KEY value = 'A'
BINARY SEARCH INTO DATA(ls_element).
ENDFUNCTION.Has anyone created such a custom Code Inspector check and can provide the code?
Thank you very much!
Sandra
NB: for information, there's also the simpler SAP internal test "Search READ .. BINARY SEARCH for unsorted results of SELECT statements" (CL_CI_TEST_SELECT_BIN_SEARCH) which does the same as CL_CI_TEST_NO_ORDER_BY for the above-described case.
Request clarification before answering.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.