cancel
Showing results for 
Search instead for 
Did you mean: 

Dublicate search field keep adding on pressing Search Button/Enter by using add_selection_param

AB069
Active Participant
0 Kudos

Hi Frds,

I tried to restict the search data in search screen by using below code, its working fine but the problem is that when ever user press Enter/ Search Button the Field 'CRETED_BY' is keep adding at the end of the search field list.

If search done 5 time then 5 CREATED_BY field get added.

  lr_qs->add_selection_param( exporting iv_attr_name = 'CREATED_BY' iv_sign = 'I'  iv_option = 'EQ' iv_low = LV_UNAME ).

Please let me know how can i avoided these dublicate field adding.

Thanks,

Imran

Accepted Solutions (1)

Accepted Solutions (1)

AB069
Active Participant
0 Kudos

Thanks Frds alot for your valueable time.

i solved my issue in other way.Below is the code in ON_SEARCH event. would be helpful for others.

 

Data: lr_qs_bcol TYPE REF TO if_bol_bo_col.
DATA: lr_entity TYPE REF TO if_bol_bo_property_access.

 

lr_query_service->insert_selection_param( iv_index = '8'
iv_attr_name
= 'CREATED_BY' iv_sign = 'I'  iv_option = 'EQ'
iv_low
= LV_UNAME iv_high = LV_UNAME ).
lr_result
= lr_query_service->get_query_result( ).
lr_qs_bcol ?= lr_query_service->get_selection_params( ).
lr_entity
= lr_qs_bcol->find( iv_index = 8 ).
lr_qs_bcol
->remove( lr_entity ).

Once the data get selected i removed it from the parameter list. this code restrict the resultcollection  to the current userid only.

Also deleting the 'CREATED_BY' search from search page by using view impl class , method GET_POSSIBLE_FIELDS , its returining parameter contain all field which are going to display at the output, so deleted field which u dont like to display.

Hope it will help.

Thanks

Imran


Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Imran,

Just like @deepika suggested, check the parameter.

Use


Data : lr_query_params type ref to IF_BOL_BO_COL.


lr_qs->get_selection_params( lr_query_params).


check the object for atribute create_user and the  add the parameter if required


Hope it works


-Anish

Message was edited by: Anish Thulasidhar

deepika_chandrasekar
Active Contributor
0 Kudos

Hi,

Check Search parameter list having CREATED_BY field before you add one more field.

Regards,

Deepika C.

AB069
Active Participant
0 Kudos

Hi Deepika,

Could you please tell how can i perform this check also how can i remove search field from the list.

It would be very helpful with some sample code.

I really appriciate your help.

Thanks

Imran

deepika_chandrasekar
Active Contributor
0 Kudos

Hi Imran,

Try to get your selection  parameter in internal table and check for you selection parameter CREATED_BY.

data:ls_fields        TYPE genilt_selection_parameter,

        lt_fields        TYPE genilt_selection_parameter_tab.

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

* Assign selection parameters to internal table

  lr_qs_col ?= lr_qs->get_selection_params( ).

  lr_param_ent = lr_qs_col->get_first( ).

  WHILE lr_param_ent IS BOUND.

    lr_param_ent->get_properties( IMPORTING es_attributes = ls_fields ).

    APPEND ls_fields TO lt_fields.

    lr_param_ent = lr_qs_col->get_next( ).

  ENDWHILE.

READ TABLE lt_fields INTO ls_fields WITH KEY attr_name = 'CREATED_BY" low = 'your value'.

    IF sy-subrc IS NOT INITIAL.

      CALL METHOD lr_qs->add_selection_param

        EXPORTING

          iv_attr_name = 'CREATED_BY'        

          iv_sign      = 'I'

          iv_option    = 'EQ'

          iv_low       = 'your value'.

    ENDIF.

Regards,

Deepika C.

AB069
Active Participant
0 Kudos

Thanks Gaurav, but its not a right solution. only at the first time it will execute the code but for next it wont execute. I want to execute my code each time without adding dublicate field at the search screen. act its a property of add_selection_param method which added the field at the search page every time when it get execute. so if is there any solution which restore Search configuration or delete search field , would be helpful.   Please suggest.

Thanks

Imran

former_member188098
Active Contributor
0 Kudos

Hi Imran,


I think you have added this code in do_prepare_output that's why its add field after every round trip.

you can add selection parameter code in events of  Enter/ Search Button etc , so that it will run only when the event executes.And after all code execution you can clear search parameters etc if you want.

Regards,

AB069
Active Participant
0 Kudos

Thanks Harish, For your reply.

I am using my code in ON_Search event only. and the problem is that user may enter or Press Search button N number of times and therefore Field will add each time. so just clear the search parameter wont help. Now the ques is that how can i remove unwanted search field at the search page.

Please suggest.


kumar5
Active Contributor
0 Kudos

Hi ,

Then you can use the 'GET_SELECTION_PARAM_TABLE' method of the query class. This table will return the selection parameters. Now check in this table whether the 'Created_by ' parameter exists or not . Only add it if its not present.

I think this will solve your problem.

Thanks

Kumar.

kumar5
Active Contributor
0 Kudos

Hi,

I think you need to use iv_first_time variable to avoid it if you are doing the code in do_prepare_output method.

If iv_first_time eq ABAP_TRUE.

     lr_qs->add_selection_param( exporting iv_attr_name = 'CREATED_BY' iv_sign = 'I'  iv_option = 'EQ' iv_low = LV_UNAME ).

Endif.

Thanks

Kumar