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: 

Determine the selected rows in ALV which has checkbox marked .

0 Kudos

I have a ALV which displays as expected. I have "Select all, Deselect All, Approve and reject" Buttons. On "Select All" all the rows are selected as expected. When i click on Approve , i am not able to use "GET_SELECTED_ROWS" of cl_gui_alv_grid since it is meant only when all rows are selected (i.e , not by checking the checkbox).

What is my solution here. Should i loop my itab n do,no method can be used?

This works and returns the no of rows when i use the cl_gui_alv_grid->GET_SELECTED_ROWS

Doesnt work in this case, Should i use itab where modified = "X" and then go to the approval process? Any suggestion?

1 ACCEPTED SOLUTION

alopezv74
Participant

If you want to get the "checked" rows instead the "selected", I think there is no other way than filter by the column with the checkbox.
You can use something like that to get all the rows selected (assuming that MODIFIED is the name column where the checkbox is set)

data(lt_checked) = VALUE ty_alvt_able( for alv_row in alv_table WHERE ( modified = abap_true ) CORRESPONDING #( alv_row ) ).

with that you will get a table with all the lines cheked.

Regards,

Adolfo

8 REPLIES 8

alopezv74
Participant

If you want to get the "checked" rows instead the "selected", I think there is no other way than filter by the column with the checkbox.
You can use something like that to get all the rows selected (assuming that MODIFIED is the name column where the checkbox is set)

data(lt_checked) = VALUE ty_alvt_able( for alv_row in alv_table WHERE ( modified = abap_true ) CORRESPONDING #( alv_row ) ).

with that you will get a table with all the lines cheked.

Regards,

Adolfo

0 Kudos

thanks adolfo.lopez I am slightly confused here.

datatab_y[] is my itab which has all fields and ls_outtab is my wa

zflag1 is the checkbox column which is all checked.

So when i write like this , i get an error . datatab_y[] is the itab whichwill have my alv output with zflag1 field as checked.

DATA(lt_checked) = VALUE lt_checked(
for ls_outtab IN datatab_y[] WHERE ( zflag1 = 'X' ) ( ls_outtab-zflag1 ) ).

Pls help. Not sure where am i going wrong.

0 Kudos

a little more information and correction.But still i get error.

   BEGIN OF g_ty_s_outtab.
INCLUDE TYPE g_ty_zaque.
TYPES:
celltab TYPE lvc_t_styl,
row_id TYPE i,
END OF g_ty_s_outtab,
g_ty_t_outtab TYPE TABLE OF g_ty_s_outtab WITH EMPTY KEY.
data : datatab_y TYPE g_ty_t_outtab WITH HEADER LINE .
Datatab_y[] has the output to be displayed in alv .
data(lt_checked) = VALUE g_ty_t_outtab( for ls_outtab IN datatab_y[] WHERE ( zflag1 = con_true )CORRESPONDING #( alv_row ) ).

Error : No component exists with the name "#". "#".

Divya Venkatakrishnan Here is the ABAP statement given by Adolfo with the syntax corrected:

data(lt_checked) = VALUE ty_alvt_able( 
    for alv_row IN alv_table
    WHERE ( modified = abap_true )
    ( CORRESPONDING #( alv_row ) ) ). " <== parentheses

Divya, as Sandra said is missin a parenthesis for the corresponding in the code.

Regards,

Adolfo

0 Kudos

@adolfo.lopez

though i have rowid in the fetched checked itab , it is all zero. It has fetched the checked rows but the row ids are not detremined. Is there a way i can find the index of the checked rows also?.

alopezv74
Participant

HiDivya.

Are the rowid filled in datatab_y[] ?

If so, just check that they ahve the same name, if not, you can use the MAPPING addition to move the value from rowid to row_id (if they have differents names).