cancel
Showing results for 
Search instead for 
Did you mean: 

How to keep selected items on ALV?

giovani_ragazzon
Explorer
0 Kudos

Hi experts,

I'm facing a problem with ABAP ALV, and after researching I couldn't find the solution for that.

In my scenario I'm dynamically creating my ALV from DB (I'm using ORM for this, in case it makes any difference), and if I have several rows on my ALV, after selecting the values I want in the "first page", if I scroll down for further selecting other items, the items I've just selected they get deselected.

When dynamically creating the ALV I've set this

     lr_interfacecontroller->get_model( )->if_salv_wd_table_settings~set_selection_mode( cl_wd_table=>e_selection_mode-multi_no_lead ).

but it doesn't solves my problem (actually I've tried different values, but none of them did the job).

I've also tried other attributes (don't remember which of them) from this interface and from other interfaces, but still with no success.

Thanks in advance for your help!

Best regards,

Giovani

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Giovani,

According to me the solution you have implemented above is perfect.

The problem that you might have occurred is that you have bind the table again on some action.

This means when you have selected the rows in first page and scrolled some hook methods are called like before_action after_action modify_view ( view hook methods ) and post_processing before_navigation ( component controller hook methods ). Please check that you have not used bind_table( ) again in any of these methods.

giovani_ragazzon
Explorer
0 Kudos

Hi Vishu,

That was exactly the case. There was another bind at after_action and that was the root cause of my problem.

Now I'm getting the selected item prior to binding the table again and after binding I'm selecting the items again.

Thanks again!

Best regards,
Giovani

Answers (4)

Answers (4)

anoop_gupta2
Participant
0 Kudos

well an easy option is to keep an attribute in node char1 , as flag , and one checkbox in the Generated Table UI , so that user can select multiple values even after scrolling down..

Best Regards,

Anoop Gupta

giovani_ragazzon
Explorer
0 Kudos

Hi Anoop,

Thanks for the suggestion. In fact I've considered the usage of checkboxes for this, but instead of going for this approach we are trying to achieve the usage of the "standard" functionality of clicking on the rows, so if there is an alternative for this we'd prefer it rather using checkboxes.

Best regards,

Giovani

kutjohn
Active Participant
0 Kudos

Hi Giovani,

Check this document http://scn.sap.com/docs/DOC-41911

giovani_ragazzon
Explorer
0 Kudos

Hi John,

I wasn't able to try this approach due to time constraints for the delivery of the project (so I don't know if it will indeed do what I need or not), but for sure it is at least helpful in order to improve the solution to not request the CTRL click for selecting the rows.

Once I'm able to try this I'll provide a more suitable response to this proposal.

Thanks and regards,

Giovani

kutjohn
Active Participant
0 Kudos

Happy to know that it was helpful in some way

Former Member
0 Kudos

Hello Giovani,

Use Change layout option in ALV grid and select required fields and save your layout.

Reward if useful

giovani_ragazzon
Explorer
0 Kudos

Hi Navneet,

Thanks for the suggestion, but it's not applicable to my problem.

The fact is that I don't have an ALV to configure in this way (it's created dynamically), but even if I had it at design time this solution wouldn't fit to my needs, as my problem is not related to displaying one or another field, but to keep selected any previously selected rows when scrolling down the ALV, for example.

Best regards,

Giovani

kutjohn
Active Participant
0 Kudos

This message was moderated.

uppu_narayan
Active Participant
0 Kudos

Hi Giovani,

      Did you try in this way....

  DATA:

      lr_salv_wd_table TYPE REF TO iwci_salv_wd_table,

      l_value TYPE REF TO cl_salv_wd_config_table,

      lr_table_settings TYPE REF TO if_salv_wd_table_settings.

      lr_salv_wd_table = wd_this->wd_cpifc_alv_child( ).

      l_value = lr_salv_wd_table->get_model( ).

     lr_table_settings ?= l_value .

     lr_table_settings->set_selection_mode( cl_wd_table=>e_selection_mode-MULTI_no_lead ).

regards,

narayan

giovani_ragazzon
Explorer
0 Kudos

Hi Narayan,

I didn't tried this way, but does this make any difference?

I mean, the code I've written does exactly the same as yours, but instead of declaring some variables and assigning them one at a time, I only directly call the methods in line...

Could you elaborate a little bit more on this topic ("in line" X declarative calling) in case it has differences, please?

Regards,

Giovani