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: 

more rows selection with cl_gui_alv_grid

Former Member
0 Kudos

Hi,

with cl_gui_alv_grid i have created table in a dynpro. In layout structure SEL_MODE is 'A' gefilled.When i choose more than 1 rows, eg. i want to choose 1st and 4th row, but in the fact i must choose from 1 to 4 rows, i had to get 4 rows.

How to solve this problem?

thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Use GET_SELECTED_ROWS.

Thanks

Kiran

17 REPLIES 17

I355602
Advisor
Advisor
0 Kudos

This message was moderated.

Former Member
0 Kudos

Use GET_SELECTED_ROWS.

Thanks

Kiran

0 Kudos

Thanks for your replies.

i would like to explain my question. I I have to select several rows in an ALV. I'm using cl_gui_alv_grid class to construct the ALV.

The layout table is filled in this way:

g_layout-zebra = 'X'.

g_layout-cwidth_opt = 'X'.

g_layout-sel_mode = 'D'.

I have the problem that I can only select several rows using Ctrl key, and I need to do this just selecting the rows with the mouse.

Thank you.

0 Kudos

Hi,

Try passing:-

SEL_MODE = 'A'.

Hope this helps you.

Regards,

Tarun

0 Kudos

i have tried with 'A'. it does not work

0 Kudos

Hi,

Use this for layout information:-


wa_layout-stylefname = 'CELLTAB'.
wa_layout-sel_mode = 'A'.

Regards,

Tarun

0 Kudos

thanks, but i does not work too. i want to choose rows randomly more than 1 rows. How to do it?

Edited by: gang qin on Aug 3, 2009 4:55 PM

0 Kudos

Hi,

I guess you are working in that ALV with the box append with each row.

Using that box you can select using CTRL button only.

If you wish to select multiple rows then proceed with a checkbox.

Keep a checkbox as a field in your internal table and use it as a selected/deselected indicator.

And pass the same code in my previous reply for layout information.

Hope this solves your problem.

Regards,

Tarun

0 Kudos

thanks,

could you give example code? I did not find it.

0 Kudos

Hi,

Refer:


TYPES : BEGIN OF t_final,
          chk      TYPE char01,      "Check
          "other field to be displayed
          celltab TYPE lvc_t_styl,   "Table to edit
        END OF t_final.

Create an internal table of this type. Now CHK will act as the select/deselect indicator.

Create the field catalog for field CHK as:-


    ls_fcat-fieldname = 'CHK'.
    ls_fcat-checkbox  = 'X'.
    ls_fcat-edit = 'X'.

Now use this checkbox to select/deselect records.

You can also refer this technique using the ALV FM.

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alv%252bgrid%252bdisplay%252bwith%252bch...

Hope this helps you.

Regards,

Tarun

0 Kudos

Thanks,

but i use method set_table_for_first_display, this structure for display is already created. That means it does not be changed.

0 Kudos

Hi,

You would need to add one more field in your internal table (which you are currently using) for the indicator, which will be used to identify whether a record is selected or deselected.

The link which i provided was just for reference. You need follow the same approach to add a checkbox to display in alv.

It was done using the FM.

All you need to do is to add those two more fields at the end of all fields in internal table and create field catalog for field CHK, rest code will work.

Now when you select a record in ALV, then the field CHK will have X for that record, and blank for others.

Use method to refresh the ALV display:-

refresh_table_display

Let me know if you have some doubts.

Thanks & Regards,

Tarun

0 Kudos

hi, i have created 1 field in my structrure for display with SE11. and data type is c(1). but in dynpro how can i let this field shown as checkbox .

0 Kudos

Hi,

Add details for that field while creating the field catalog:-

Refer:-


    ls_fcat-tabname   = 'IT_FINAL'.
    ls_fcat-edit      = 'X'.
    ls_fcat-fieldname = 'CHK'.
    ls_fcat-checkbox  = 'X'.
    ls_fcat-coltext   = ''.
    ls_fcat-col_pos   = 1.
    ls_fcat-outputlen = 3.
    APPEND ls_fcat TO pt_fcat.  "<<--- pass this pt_fcat in the method
    CLEAR ls_fcat.

For layout use:-


      v_layout-stylefname = 'CELLTAB'.
      v_layout-sel_mode = 'A'.

Hope this helps you.

Regards,

Tarun

0 Kudos

it cause an error. i do not know where it is?

lc_wa_fcat-tabname = 'IT_FINAL'.

lc_wa_fcat-edit = 'X'.

lc_wa_fcat-fieldname = 'CHK'.

lc_wa_fcat-checkbox = 'X'.

lc_wa_fcat-coltext = ''.

lc_wa_fcat-col_pos = 1.

lc_wa_fcat-outputlen = 3.

APPEND lc_wa_fcat TO lc_tb_fcat. "<<--- pass this pt_fcat in the method

CLEAR lc_wa_fcat.

if gl_rd_grid is not bound.

create object gl_rd_grid

EXPORTING

i_parent = gl_rd_cont.

  • setcolor?

  • lc_wa_layout-info_fname = 'LINECOLOR'.

  • lc_wa_layout-grid_title = space.

  • ls_layout-no_toolbar = 'X'.

lc_wa_layout-CWIDTH_OPT = 'X'.

  • lc_wa_layout-edit = 'X'.

  • lc_wa_layout-no_rowmove = 'X'.

  • lc_wa_layout-no_rowins = 'X'.

*

lc_wa_layout-stylefname = 'CELLTAB'.

lc_wa_layout-ctab_fname = 'COLORTAB'.

  • lc_wa_layout-zebra = 'X'.

lc_wa_layout-sel_mode = 'A'.

clear lc_wa_variant.

lc_wa_variant-report = sy-cprog.

lc_wa_variant-handle = '0001'.

call method gl_rd_grid->set_table_for_first_display

EXPORTING

is_layout = lc_wa_layout

  • is_variant = lc_wa_variant

  • i_save = 'A'

  • i_default = 'X'

it_toolbar_excluding = lc_tb_excl

CHANGING

it_outtab = gl_tb_output_1000

it_fieldcatalog = lc_tb_fcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

0 Kudos

Can you please tell me what is the error you get?

Regards,

Tarun

Former Member
0 Kudos

In the field catalog, while you are passing the FIELDNAME, make sure, u r passing the correct field name of ur itab. and also pass SELMODE = 'A'.

This will solve.

Thanks

Kiran