Friday, 21 December 2012

SEARCH VIEW



oct 6
 serch view on custom fields
 add and remove on screen

method EH_ONSEARCH.

  
data : lr_qs type ref to cl_crm_bol_dquery_service,
         lr_param_col 
type ref to if_bol_bo_col,
         lr_entity 
type ref TO if_bol_bo_property_access,
         wa_param 
type genilt_selection_parameter,
         it_sel_target 
type STANDARD TABLE OF selopttab,
         wa_sel 
type selopttab,
         it_data 
type STANDARD TABLE OF zoppt_enHAnce15,
         wa_data 
type zoppt_enhance15,
         V_LOW 
TYPE STRING.

  lr_qs ?= typed_context->search->collection_wrapper->get_current( ).

  save_ui_search_criteria( 
EXPORTING ir_qs = lr_qs ).

  lr_param_col ?= lr_qs->get_selection_params( ).

  lr_entity ?= lr_param_col->get_first( ).

  
while lr_entity is bound.
    lr_entity->get_properties( 
IMPORTING es_attributes = wa_param ).

    
if wa_param-attr_name = 'OPPT_TARGET'.
      
MOVE-CORRESPONDING wa_param to wa_sel.
      
append wa_sel to it_sel_target.
    
endif.

    lr_entity ?= lr_param_col->get_next( ).
  
endwhile.

  
SELECT * from zoppt_enhance15 into TABLE it_data
      
where oppt_target in it_sel_target.

  
loop at it_data INTO WA_DATA.
    V_LOW = WA_DATA-OPPT_ID.
    
CALL METHOD LR_QS->ADD_SELECTION_PARAM
      
EXPORTING
        IV_ATTR_NAME = 
'OBJECT_ID'
        IV_SIGN      = 
'I'
        IV_OPTION    = 
'EQ'
        IV_LOW       = V_LOW.
*       IV_HIGH      =

  
ENDLOOP.

  
CALL METHOD SUPER->EH_ONSEARCH
    
EXPORTING
      HTMLB_EVENT    = HTMLB_EVENT
      HTMLB_EVENT_EX = HTMLB_EVENT_EX.

restore_ui_search_criteria( 
EXPORTING ir_qs = lr_qs ).

endmethod.

_____________________________________
SAVE_UI_SEARCH_CRITERIA(copied std method with "importing para : ir_qs")

METHOD SAVE_UI_SEARCH_CRITERIA.

  
DATA: lr_selparam_col TYPE REF TO if_bol_bo_col.

  
CALL METHOD ir_qs->get_selection_params
    RECEIVING
      rv_result = lr_selparam_col.

  
DATA: lv_iterator  TYPE REF TO if_bol_bo_col_iterator,
        lv_param     
TYPE REF TO if_bol_bo_property_access.
  
DATA: ls_selection TYPE genilt_selection_parameter.

  
REFRESH gt_original_search_criteria.

  
TRY.
      lv_iterator = lr_selparam_col->get_iterator( ).
      lv_param    = lv_iterator->get_first( ).
      
WHILE lv_param IS BOUND.
*       Get the attributes out
        lv_param->get_properties( 
IMPORTING es_attributes = ls_selection ).
* save in global instance varialbe for later reuse.
        
APPEND ls_selection TO gt_original_search_criteria.
*       Get all the entitys from the collection
        lv_param = lv_iterator->get_next( ).
      
ENDWHILE.
    
CATCH cx_sy_ref_is_initial.                         "#EC NO_HANDLER
  
ENDTRY.

ENDMETHOD.
________________________________________
RESTORE_UI_SEARCH_CRITERIA(copied std method with "importing para : ir_qs")


METHOD RESTORE_UI_SEARCH_CRITERIA.

  
DATA: col TYPE REF TO if_bol_bo_col.
  
FIELD-SYMBOLS: <ls_selection_parameters> TYPE genilt_selection_parameter.

  col = ir_qs->get_selection_params( ).

* clear the selection parameter collection....
  
CALL METHOD col->clear .

  
LOOP AT gt_original_search_criteria ASSIGNING <ls_selection_parameters>.

* to have the original UI selection param table for the search
    
CALL METHOD ir_qs->add_selection_param
      
EXPORTING
        iv_attr_name = <ls_selection_parameters>-attr_name
        iv_sign      = <ls_selection_parameters>-
sign
        iv_option    = <ls_selection_parameters>-option
        iv_low       = <ls_selection_parameters>-low
        iv_high      = <ls_selection_parameters>-high.

  
ENDLOOP.

ENDMETHOD.

_______________________________

No comments:

Post a Comment