METHOD EH_ONSEARCH.*CALL METHOD SUPER->EH_ONSEARCH** EXPORTING** HTMLB_EVENT =** HTMLB_EVENT_EX =* . DATA: LR_QUERY_SERVICE TYPE REF TO CL_CRM_BOL_DQUERY_SERVICE, LR_MESSAGE_SERVICE TYPE REF TO CL_BSP_WD_MESSAGE_SERVICE, LV_MESSAGE TYPE STRING, LR_SEL_PARAMS TYPE REF TO IF_BOL_BO_COL, LR_PARAM TYPE REF TO IF_BOL_BO_PROPERTY_ACCESS, LR_ITERATOR TYPE REF TO IF_BOL_BO_COL_ITERATOR, LS_SELECTION TYPE GENILT_SELECTION_PARAMETER, LT_PARAMS TYPE GENILT_SELECTION_PARAMETER_TAB, LV_MAX_HITS TYPE I, LR_VALUENODE TYPE REF TO CL_BSP_WD_VALUE_NODE, GS_CLAUSE TYPE STRING, GT_CLAUSE TYPE TABLE OF STRING, GT_EKKO TYPE TABLE OF EKKO, GW_EKKO TYPE EKKO.. "获取当前查询节点 LR_QUERY_SERVICE ?= ME->TYPED_CONTEXT->SEARCHQUERYNODE->COLLECTION_WRAPPER->GET_CURRENT( ). "检查查询节点实例化 CHECK LR_QUERY_SERVICE IS BOUND. "清空结果节点内容 ME->TYPED_CONTEXT->SEARCHRESULTNODE->COLLECTION_WRAPPER->CLEAR( ). "获取查询对象 LR_SEL_PARAMS = LR_QUERY_SERVICE->GET_SELECTION_PARAMS( ). "获取最大值 LR_QUERY_SERVICE->GET_PROPERTY_AS_VALUE( EXPORTING IV_ATTR_NAME = 'MAX_HITS' IMPORTING EV_RESULT = LV_MAX_HITS ). "获取查询对象的BOL迭代器^_^ LR_ITERATOR = LR_SEL_PARAMS->GET_ITERATOR( ). "迭代器循环获取查询对象的值 LR_PARAM = LR_ITERATOR->GET_FIRST( )."自己做的动态查询拼接 WHILE LR_PARAM IS BOUND. LR_PARAM->GET_PROPERTIES( IMPORTING ES_ATTRIBUTES = LS_SELECTION ). IF LS_SELECTION-LOW IS NOT INITIAL OR LS_SELECTION-HIGH IS NOT INITIAL."选择条件有值 IF LS_SELECTION-LOW IS NOT INITIAL AND LS_SELECTION-HIGH IS NOT INITIAL AND LS_SELECTION-OPTION = 'BT'. CONCATENATE LS_SELECTION-ATTR_NAME 'BETWEEN' LS_SELECTION-LOW 'AND' LS_SELECTION-HIGH INTO GS_CLAUSE SEPARATED BY ' '. ENDIF. IF LS_SELECTION-LOW IS NOT INITIAL. CONCATENATE LS_SELECTION-ATTR_NAME LS_SELECTION-OPTION LS_SELECTION-LOW INTO GS_CLAUSE SEPARATED BY ' '. ENDIF. APPEND GS_CLAUSE TO GT_CLAUSE. ENDIF.* APPEND LS_SELECTION TO LT_PARAMS. LR_PARAM = LR_ITERATOR->GET_NEXT( ). ENDWHILE."数据查询 SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_EKKO FROM EKKO WHERE (GT_CLAUSE). DATA: LR_REF_ANY TYPE REF TO DATA, LR_VALUE_NODE TYPE REF TO CL_BSP_WD_VALUE_NODE."值类型转化添加到结果 LOOP AT GT_EKKO INTO GW_EKKO. GET REFERENCE OF GW_EKKO INTO LR_REF_ANY. CREATE OBJECT LR_VALUE_NODE TYPE CL_BSP_WD_VALUE_NODE EXPORTING IV_DATA_REF = LR_REF_ANY. ME->TYPED_CONTEXT->SEARCHRESULTNODE->COLLECTION_WRAPPER->ADD( LR_VALUE_NODE ). ENDLOOP. ENDMETHOD.