Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How can i know how many records are selected in an alv grid?

0 Kudos

Well here is my code

      WHEN 'BORRAR_PRO'.

DO 2 TIMES.
READ TABLE gt_doc_txt INTO wa_doc_txt INDEX ps_selfield-tabindex.
DELETE gt_doc_txt
WHERE cod_producto = wa_doc_txt-cod_producto.
ENDDO.

it works when i hardcode the times of the do, but i need to know how many record are selected to know how many times the do have to work.

The code are in the user_command USING pv_ucomm.

4 REPLIES 4

moshenaveh
Community Manager
Community Manager
0 Kudos

Welcome to the SAP Community. Thank you for visiting us to get answers to your questions.

Since you're asking a question here for the first time, I'd like to offer some friendly advice on how to get the most out of your community membership and experience.

First, please see https://community.sap.com/resources/questions-and-answers, as this resource page provides tips for preparing questions that draw responses from our members. Second, feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html, as that will help you when submitting questions to the community.

I also recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

Now for some specific suggestions on how you might improve your question:

* Outline what steps you took to find answers (and why they weren't helpful) -- so members don't make suggestions that you've already tried.

Should you wish, you can revise your question by selecting Actions, then Edit.

The more details you provide (in questions tagged correctly), the more likely it is that members will be able to respond.

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

VXLozano
Active Contributor

Which kind of ALV? CL_SALV_TABLE or the old CL_GUI_ALV_something? If it's something oldie like the FM 'REUSE_ALV', I fear I cannot tell you, I'm old, but a failsafe device on my memory prevents me to access data from those dark years when I was used to FM's and FORMs...

raymond_giuseppi
Active Contributor
0 Kudos

Well, suppose user selected 10th and 20th record, so cursor is on line 20... your code delete 20th record 2 time, previously records 20 and 21... 😞

Time to switch to CL_GUI_ALV_GRID (edit?) or CL_SALV_TABLE or to read IS_LAYOUT documentation in some outdated FM ... HTPP error 419 ...

0 Kudos

Thanks to all, i just create a new column with a checkbox, and the user have to put X on the records who wants to delete. Thanks to all, it is my first question here.