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 to highlight an entry in ALV Grid created using class CL_GUI_ALV_GRID

Francis417
Participant
0 Kudos

Hi,

I've a program making use of the class CL_GUI_ALV_GRID to create an ALV grid, upon hitting particular condition, I want to highlight a particular row in the ALV grid. However, I've no idea how it can be achieved. Appreciate if all of the experts here can give me some hints and suggestions on how I can make it work.

Thanks,

Francis

1 ACCEPTED SOLUTION

Former Member
0 Kudos

When using CL_GUI_ALV_GRID..to highlight a particular row...

Step1 To the structure of GT_OUTTAB (your final table) add a field ...say RC(4)

Step2 Now after selecting data - loop at gt_outtab and based on your condition set RC = '5'. and modify gt_outtab[].

Step3 In the layout gs_layout-info_fname = 'RC'.

Then CALV->SET_TABLE_FOR_FIRST_DISPLAY and pass LAYOUT.

8 REPLIES 8

Former Member
0 Kudos

When using CL_GUI_ALV_GRID..to highlight a particular row...

Step1 To the structure of GT_OUTTAB (your final table) add a field ...say RC(4)

Step2 Now after selecting data - loop at gt_outtab and based on your condition set RC = '5'. and modify gt_outtab[].

Step3 In the layout gs_layout-info_fname = 'RC'.

Then CALV->SET_TABLE_FOR_FIRST_DISPLAY and pass LAYOUT.

0 Kudos

Dear Ncvajja,

Thanks for your help. Just want to ask one more question, after adding such field, how can I remove it from the list of available columns in the ALV grid so that user will not 'see' this field and will not be able to select it and display in the grid by changing the layout?

Thanks,

Francis

0 Kudos

Ohh user will not see this field..

Also add this only to gt_outtab and not the fieldcatalog. or anywhere else.

Try analysing BCALV_EDIT_01-08. They can help you understand better.

0 Kudos

Hi Ncvajja,

After modifying the desired row in gt_outtab[ ] with the value '5' and calling set_table_for_first_display, it doesn't seems to work and the desired row is not highlighted/selected. any suggestions or idea what went wrong?

By the way, is it a must to call set_table_for_first_display to have the highlight effective? I wonder if it is also possible for refresh_table_display?

Thanks,

Francis

Edited by: Francis S.K. LUK on Feb 6, 2012 1:00 PM

0 Kudos

My friend... RC = '5'. was just a random number....

Please use colors as in RC = 'C410'.

I'm not sure of the list of colors but they are 400,410,420,430...till 700 series.

ohh make sure that the C is in caps

Edited by: Ncvajja on Feb 6, 2012 6:11 AM

0 Kudos

Hi Ncvajj,

Still doesn't work with the following codes. Any ideas what I've done wrong?


    describe table err_cell lines err_cnt.
    if err_cnt > 0.
      loop at err_cell into tmp_chg.
        if tmp_chg-typ = 'C'.
          call method er_data_changed->add_protocol_entry
            exporting
             i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
             i_msgv1 = text-m01  
             i_fieldname = tmp_chg-fieldname
             i_row_id = tmp_chg-row_id.
        elseif tmp_chg-typ = 'R'.
          call method er_data_changed->add_protocol_entry
            exporting
             i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
             i_msgv1 = text-m02  
             i_fieldname = tmp_chg-fieldname
             i_row_id = tmp_chg-row_id.
        endif.
        read table gt_outtab index tmp_chg-row_id into gs_outtab.
        gs_outtab-rc = 'C410'.
        modify table gt_outtab from gs_outtab.
      endloop.
      call method er_data_changed->display_protocol.
      ls_lvc_s_stbl = 'XX'.
"       call method g_grid->refresh_table_display
"        exporting is_stable = ls_lvc_s_stbl.
    call method g_grid->set_table_for_first_display
      exporting "i_structure_name     = 'ZHR_APP5_7'
                "is_variant           = w_is_variant
                "i_save               = wk_save
                is_layout            = gs_layout
                "it_toolbar_excluding = gs_toolbar_excluding[]
      changing  it_outtab            = gt_outtab[]
                it_fieldcatalog      = gt_fieldcatalog.

    endif.

Edited by: Francis S.K. LUK on Feb 6, 2012 1:42 PM

former_member184578
Active Contributor
0 Kudos

Hi Fransis,

You can use method set_selected_rows of cl_gui_alv_grid. You need to append the row numbers and passit to the specified method,

data lr_grid type ref to cl_gui_alv_grid.

lr_grid->set_table_for_first_display(
...

loop your output itab, and add the rows to lt_rows if the condition satisfies


lr_grid->set_selected_rows
   EXPORTING
      IT_ROW_NO  =  lt_rows.     here lt_rows is internal table of type LVC_T_ROID.

Or,

You can take one extra field 'color' in your structure , and populate the field 'color' if the condition satisfies, and you can set the layout accordingly to color the particular rows.

Hope this helps u.,

Thanks & regards,

Kiran.

Francis417
Participant
0 Kudos

Thanks for all the advises, problem solved by using the set_selected_row method followed by the method cl_gui_cfw=>flush.