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: 

Checkbox in ALV

Former Member
0 Kudos
94

Hi,

I have searched this problem on this site but still unable to find a solution,

I am displaying some output in ALV which is having an editable check box as its first column.

I am using REUSE_ALV_GRID_DISPLAY to display the ALV output.

on some conditions , few checkboxex in the output are coming as checked (X). Now I want to uncheck few records from the checked records on the output screen and do some processing on these unchecked records . how can I get these uncheck records in the program control?

I am using PF-Status in the ALV.

I am also trying to get the chenged data like this

In user command:

when 'SAVE'.

DATA : REF_GRID TYPE REF TO CL_GUI_ALV_GRID.

IF REF_GRID IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = REF_GRID.

ENDIF.

IF NOT REF_GRID IS INITIAL.

CALL METHOD REF_GRID->CHECK_CHANGED_DATA.

ENDIF.

as expected this should update the internal table with changed records from the output screen but this is not working....I am unable to figure out what is missing here...

Please help me ...

Thanks,

niel.

6 REPLIES 6

former_member194669
Active Contributor
0 Kudos
59

Say BOX is the field name in your output table passing to REUSE_ALV_GRID_DISPLAY


    call function 'REUSE_ALV_GRID_DISPLAY'
      exporting
        it_fieldcat                 = i_fieldcat[]
        is_layout                   = pt_grplayout2
        i_callback_program          = 'YSDDU0007'
        i_callback_html_top_of_page = p_header
        i_callback_user_command     = 'F_USER_COMMAND1'
        it_events                   = i_events[]
      tables
        t_outtab                    = i_output.

form f_user_command1 using p_ucomm type sy-ucomm
                     rs_selfield type  slis_selfield.

  data p_ref1 type ref to cl_gui_alv_grid.
  call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    importing
      e_grid = p_ref1.
  call method p_ref1->check_changed_data.
  loop at i_output where box eq space.
       " Do your validation here 
  endloop.
  rs_selfield-refresh = c_x.             " Grid refresh


endform.                                 " F_user_command1
*

0 Kudos
59

Hi A@S,

As I explained in my question , I have few unchecked and checked records in the output and I am again unchecking few records from the checked ones...how will I diifferentiate between the new unchecked ones and the earlier unchecked ones...

In your reply , you have metioned to loop the final table where the checbox is space...I think that will again be a problem because there can be old unchecked and new unchecked records..

Former Member
0 Kudos
59

Hi ,

You need to call one function in the module USER_COMMAND_0100 under your PAI.

Say the function name is "get_alv_data " .

Code this function as follows : -

PERFORM get_alv_data CHANGING it_tab[]. -


This is call to function under MODULE USER_COMMAND_0100

Coding inside the functions should be as follows : -

FORM get_alv_data CHANGING tt_tab TYPE STANDARD TABLE.

DATA: l_valid TYPE c.

CLEAR l_valid.

CALL METHOD alv_grid->check_changed_data

IMPORTING

e_valid = l_valid.

CALL METHOD alv_grid->refresh_table_display.

ENDFORM. " get_alv_data

It works... Please try this and Let us know.

Regards,

Nikhil Joshi

0 Kudos
59

Hi Nikhil,

Thanks for the reply, but its not working in my case..

I would again try to explain my problem:

I have a report in which I can see some checkboxes coming checked and from these checked checkboxes I am unchecking few records and want to do some processing on these new unchecked records( I have few unchecked record coming on my report with the checked ones ) . I want to know how to get these new unchecked records back to the internal table...I hope I am clear enough in explaining the problem...

Please Gurus.. help me here

Thanks,

Niel.

0 Kudos
59

Hi Niel ,

I got your Problem.

I will suggest that you add one more field to your internal table which will hold the value of check box initially.

Now after the execution of the Function I suggested you in my previous reply ( That is after refreshing the internal table from the new values of ALV displayed table) ; you compare this added field with the new value of check box.

Do some simple looping on the internal table where the value of check box is not equal to the value of the newly added field. The records from the internal table that meets the above codition are the records that you are looking for.

Got it ?

Please get back to me in case of any doubt.

regards,

Nikhi Joshi.

Former Member
0 Kudos
59

Hello,

Tell me one thing is it a standard report. If it standard report please provide the report name.

Check the internal table correctly when ever a check box is ticked in the internal table it is marked as 'X'.

or we have some other conditions.

Give me some clear desciption of the problem.?