Application Development and Automation 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: 
Read only

Selecting some columns when selecting a row

Former Member
0 Likes
1,115

Hi All.

Is there any way where, if I select a single row of an ALV Grid with 5 fields then only 2 fields are selected and rest are not even higlighted .

Hi All.

Is there any way where, if I select a single row of an ALV Grid with 5 fields then only 2 fields are selected and rest are not even higlighted .

5 REPLIES 5
Read only

Former Member
0 Likes
1,067

????

What do you actually want to do.

If you select a row then the whole row is automatically selected (click the box to the left of the first column on the grid).

If you select individual cells just use the shift button and select the cells you want.

Ensure however that in your layout the sel_mode is set to 'D'.

I think that if you select a whole row then you will get ALL columnsin that row. I could be wrong however.


DATA: struct_grid_lset TYPE lvc_s_layo.
.......
Program code
....

before displaying grid


struct_grid_lset-sel_mode = 'D'.

* set event handlers etc etc
 CALL METHOD grid1->set_table_for_first_display
    EXPORTING is_layout =  struct_grid_lset
    CHANGING
               it_outtab       = <dyn_table>
               it_fieldcatalog = it_fldcat.

cheers

jimbo

Read only

Former Member
0 Likes
1,067

Hi Jimbo,

Thanks for the reply. But my concern is when i Click the left most box to select the row, I want only 2 columns to be selected out of the 5 columns present.

Let me explain in detail

Lets say i have an alv consisting of 5 columns.

SOBST MINBE EISBE PRWUG PRWOG with values given below

10 50 60 80 100

20 40 70 90 200

Now if i select the any of the row, only SOBST and MINBE fields should be selected and rest (EISBE , PRWUG and PRWOG ) should be ignored.

I hope i am able to explain myself!

Read only

0 Likes
1,067

I don't think this is possible with the current technology of the alv grid..

You'll either have to train your users to select individual cells

or get them to select by COLUMNS so that might be a get around.

You could do it programatically i.e note the row the user has selected and just ignore the cells you don't want to process.

To select Columns just place the cursor over the column title.

Note you need to have the layout option sel_mode set to A,B,C,or D depending on what you need.

Cheers

jimbo

Read only

Former Member
0 Likes
1,067

If this is the solution , then i will try to program it. Thanks for your help

Regards

Gopal

Read only

0 Likes
1,067

Hi there

I think the columns approach is better but of course you then select the ENTIRE column which might not be what the user wants - especially if the table is very large.

In either case you get the "Selected Columns" back into your program so just ignore the columns you don't want to process.

I am almost 100% certain when you select a row the entire row is actually selected.

Another approach (involves an extra step) is for the user to select the rows to process as well as the columns.

Then you read the selected rows and do a REFRESH GRID. After REFRESH GRID set selected cells to the columns you want in the new display. Only the columns you actually want processd will be highlighted. Have a toolbar button CONFIRM PROCESSING or whatever.

If you need to process a variable number of columns you can still get the user to choose the rows but also select the columns to process. This way you just process the Row numbers selected using the fields of the chosen columns.

Note it might seem confusing but you need to set the selected cells AFTER calling the GRID_REFRESH since your method is executed completely before the re-display occurs.

If you call SET_SELECTED_SELLS before the GRID REFRESH the refresh will start again from the top of the table and your selection will be lost.

Cheers

jimbo