Probably every ABAP developer was already in the situation to search for an existing data element to be used in a new program/table/structure. The search help in SE11 only covers the basic needs for searching an existing data element. While you are able to find a data element using one of the existing texts (and there are five texts for each data element) and/or the data type/length, at least the lower case flag is not visible in the search result. The UI of the search result is also really old fashioned.
To solve this issue we built a report which will make a select to the DDIC tables holding the data element values. This select basically just consumes one DDL view:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@AbapCatalog.sqlViewName: 'ZBC_DTEL_SEARCHV'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Dataelement Search'
define view ZBC_DTEL_SEARCH as select from dd04l
left outer join dd04t
on dd04t.rollname = dd04l.rollname
and dd04t.ddlanguage = $session.system_language
{
key dd04l.rollname,
dd04l.domname,
dd04l.datatype,
dd04l.leng,
dd04l.decimals,
dd04l.lowercase,
dd04t.ddtext,
dd04t.reptext,
dd04t.scrtext_s,
dd04t.scrtext_m,
dd04t.scrtext_l
}
Using the following select will enable searching for all different test fields (but case sensitive, since casting the fields to lower case is not possible with our basis release):
1
2
3
4
5
6
7
8
9
10
11
12
13
SELECT *
FROM zbc_dtel_searchv
INTO TABLE @lt_result
WHERE rollname IN @s_rolnam
AND datatype IN @s_type
AND leng IN @s_leng
AND decimals IN @s_deci
AND ( lowercase IN @s_text
OR ddtext IN @s_text
OR reptext IN @s_text
OR scrtext_s IN @s_text
OR scrtext_m IN @s_text
OR scrtext_l IN @s_text ).
The problems here are that the search is being done case sensitive (since only the field lowercase
is guaranteed to be actually lower case - whereas the others are not) and we do have a lack of fuzzyness in the search. Fortunately HANA gives us the option to implement a fuzzy search with AMDB code pushdown.
Implementing this fuzzy search with AMDB has been done with the following method:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
METHOD search_fuzzy BY DATABASE PROCEDURE
FOR HDB LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING zbc_dtel_searchv.
rt_result = SELECT * FROM zbc_dtel_searchv
WHERE CONTAINS (ddtext, :iv_text, FUZZY( 0.5 ))
OR CONTAINS (reptext, :iv_text, FUZZY( 0.9 ))
OR CONTAINS (scrtext_s, :iv_text, FUZZY( 0.9 ))
OR CONTAINS (scrtext_m, :iv_text, FUZZY( 0.9 ))
OR CONTAINS (scrtext_l, :iv_text, FUZZY( 0.9 ))
ORDER BY score() DESC;
ENDMETHOD.
Which can be called by our report:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
zcl_dtel_search_helper=>search_fuzzy(
EXPORTING
iv_text = p_text
IMPORTING
rt_result = lt_result
).
LOOP AT lt_result ASSIGNING FIELD-SYMBOL(<row>)
WHERE rollname IN s_rolnam
AND datatype IN s_type
AND leng IN s_leng
AND decimals IN s_deci
AND lowercase IN s_lower.
APPEND <row> TO gt_outtab.
ENDLOOP.
By putting the results into an ALV grid we got a super fast and flexible data element search: