@AbapCatalog.sqlViewName: 'Zfuzzy_search'
@AbapCatalog.compiler.CompareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Fuzzy Search'
define view ZFuzy_Srch as select from scarr {
carrid,
carrname,
currcode,
url
}
CLASS zcl_fuzy_srch DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
interfaces IF_AMDP_MARKER_HDB.
*** --- Custom Structure
TYPES: BEGIN OF ty_airlines,
CARRID TYPE S_CARR_ID,
CARRNAME TYPE S_CARRNAME,
CURRCODE TYPE S_CURRCODE,
URL TYPE S_CARRURL,
end of TY_AIRLINES.
*** --- Table Type
types: tt_airlines TYPE TABLE OF ty_airlines .
class-methods Airlines_GLBSRCH
importing
value(im_CARRNAME) type S_CARRNAME
exporting
value(Ex_GLBSRCH) type tt_airlines.
ENDCLASS.
CLASS zcl_fuzy_srch IMPLEMENTATION.
METHOD Airlines_GLBSRCH BY DATABASE PROCEDURE FOR HDB
LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING Zfuzzy_search.
Ex_GLBSRCH = select CARRID,CARRNAME,CURRCODE,URL
from Zfuzzy_search
where
(
contains( CARRID, :im_CARRNAME, fuzzy( 1.0) ) or
contains( CARRNAME, :im_CARRNAME, fuzzy( 1.0) )
)
;
endmethod.
ENDCLASS.
Now we need to map our CDS Database/SQL view(Zfuzzy_search) and CDS entity(ZFuzy_Srch). on click on the map to data source popup populates to select CDS business entity:
METHOD fuzzyset_get_entityset.
*** --- Data Declarations
DATA:lv_carrname TYPE s_carrname.
*** --- Class Instantion
DATA(obj) = NEW zcl_fuzy_srch( ).
*** --- Get Filters
LOOP AT it_filter_select_options INTO DATA(ls_filters).
CASE ls_filters-property.
WHEN 'Carrname'.
IF ls_filters-select_options[ 1 ]-low IS NOT INITIAL.
lv_carrname = ls_filters-select_options[ 1 ]-low.
ENDIF.
ENDCASE.
ENDLOOP.
*** --- Get The Airline details
obj->airlines_glbsrch(
EXPORTING
im_carrname = lv_carrname
IMPORTING
ex_glbsrch = DATA(ls_data)
).
IF ls_data IS NOT INITIAL.
et_entityset = CORRESPONDING #( ls_data ).
ENDIF.
IF et_entityset IS NOT INITIAL.
** -- Inline Count
es_response_context-inlinecount = lines( et_entityset ).
** -- Paging
CALL METHOD /iwbep/cl_mgw_data_util=>paging
EXPORTING
is_paging = is_paging
CHANGING
ct_data = et_entityset.
ENDIF.
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 |
---|---|
11 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |