Default row selected in alv grid
Hi Everyone,
I have couple of alv screens. By default the topmost cell is highlighted in the first grid, the data of second grid is dependant on the first one. So if the topmost record is selected by default in first grid, i want to highlight its corresponding records in the second grid.
How do I achieve this.
Any help on this will be of great use to me.
Thanks in advance,
Prashant.
In PAI,
MODULE user_command_9001 INPUT.
REFRESH i_fieldrows.
<b>CALL METHOD o_alvgrid->get_selected_rows
IMPORTING
et_index_rows = i_fieldrows.</b> LOOP AT i_fieldrows INTO w_fieldrows.
READ TABLE i_output INTO w_output INDEX w_fieldrows-index.
ENDLOOP.
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
WHEN 'MD04'.
IF w_output-matnr IS INITIAL.
MESSAGE i001 WITH text-e07.
ELSE.
SET PARAMETER ID 'MAT' FIELD w_output-matnr.
SET PARAMETER ID 'WRK' FIELD w_output-werks.
CALL TRANSACTION 'md04' AND SKIP FIRST SCREEN .
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
Similarly in the next screen PAI,
use
CALL METHOD o_alvgrid->set_selected_rows
IMPORTING
et_index_rows = i_fieldrows.
Similar Messages
-
Row Selection in ALV Grid created using CL_GUI_ALV_GRID
Hi,
I have ALV grid using cl_gui_alv_grid. I want to capture the row selection and display the selected rows in 2nd ALV grid (using cl_gui_alv_grid).
Method CALL METHOD Grid->get_selected_rows giving right no. of selected records first time and process these records by POST button and hence shows these records in next alv grid. but when i came back to 1st ALV by pressing BACK button on 2nd ALV then if I again select records on the same 1st ALV grid the same Method CALL METHOD Grid->get_selected_rows fires again. but this times it wouldn't give the selected records. I mean first time this gives me correct no. of selected records but 2nd time wouldn't.
how do I capture the row selection.?
Kindly suggest me. helpful answer will be appreciated.
Thanx in Advance.
RobinHi,
Write this code, you have to free the container.
MODULE user_command_0101 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
c_container->free( ).
c_container1->free( ). " this is the container of secondary list.
clear: r_grid, r_grid1, c_container, c_container1.
LEAVE TO SCREEN 100.
ENDCASE.
Regards and Best wishes. -
HI,
I want to make my ALV Grid only single row select enabled, can some one guide me which variable should be set for the same.
Thanks and Regards,
HarshIf you are using OO for alv then
call method grid1->get_selected_rows
importing
et_index_rows = i_sel_alvrows[].
call method cl_gui_cfw=>flush.
describe table i_sel_alvrows lines v_dbcnt.
if i_sel_alvrows[] is initial.
* Info message : Please select a row
message i176. " Please select a row'.
endif.
if v_dbcnt gt 1.
* Info message : Multiple Row Selection not possible
message i177. " Multiple Row Selection not
" possible'
endif.
or if your using REUSE then
form user_command using p_ucomm type sy-ucomm
rs_selfield type slis_selfield.
" Check the rs_selfield-tabindex value here
" you may get some clue here
endform.
a® -
How to set only one row selection in ALV GRID DISPLAY
How to set single row selection in grid display
not multiselection.Hi,
In the USER COMMAND, build the code to check the REFRESHED Data & then check the number of records with SEL = 'X'.
If more than single entry found, then raise an error message.
Best regards,
Prashant -
Hi ,
Have a requirement where in all the rows in ALV should be selected defaultly.
Thanks.
Regards,
SuvarnaHi suvarna,
just add ,
wa_layout-sel_mode = c_a.
this to ur ALV layout.
u will get default selection mode.
here c_a is 'A'.
Regards,
kk. -
Urgent : how to select the rows in the ALV Grid Control
How to select the rows in the ALV Grid control,
I am facing the situation where i need to select the row/rows in the Grid control and then to lock the entries,
If anyone have the solution please help me out
<b>Its very Urgent</b>Hi Bharath,
Go through this hope u can understand.
SEL_MODE. Selection mode, determines how rows can be selected. Can have the following values:
A Multiple columns, multiple rows with selection buttons.
B Simple selection, listbox, Single row/column
C Multiple rows without buttons
D Multiple rows with buttons and select all ICON
Setting and getting selected rows (Columns) and read line contents
You can read which rows of the grid that has been selected, and dynamic select rows of the grid using methods get_selected_rows and set_selected_rows. There are similar methods for columns.
Note that the grid table always has the rows in the same sequence as displayed in the grid, thus you can use the index of the selected row(s) to read the information in the rows from the table. In the examples below the grid table is named gi_sflight.
Data declaration:
DATA:
Internal table for indexes of selected rows
gi_index_rows TYPE lvc_t_row,
Information about 1 row
g_selected_row LIKE lvc_s_row.
Example 1: Reading index of selected row(s) and using it to read the grid table
CALL METHOD go_grid->get_selected_rows
IMPORTING
et_index_rows = gi_index_rows.
DESCRIBE TABLE gi_index_rows LINES l_lines.
IF l_lines = 0.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
textline1 = 'You must choose a valid line'.
EXIT.
ENDIF.
LOOP AT gi_index_rows INTO g_selected_row.
READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
ENDIF.
ENDLOOP.
Example 2: Set selected row(s).
DESCRIBE TABLE gi_index_rows LINES l_lines.
IF l_lines > 0.
CALL METHOD go_grid->set_selected_rows
exporting
it_index_rows = gi_index_rows.
ENDIF.
Reward points if helpful.
Thanks
Naveen khan -
How do I find an event which is triggered on line selection for ALV grid?
Hi,
I'm trying to find an event which is triggered when a user selects a row in the ALV grid. I want to add my own code in to add up the total values of selected lines, but can't find any event which will trigger my method.
I found CLICK_ROW_COL but it's protected so when I try and add a method for it:
PROTECTED SECTION.
METHODS:
select_row
FOR EVENT click_row_col OF cl_gui_alv_grid.
I get the syntax error:
Access to protected event "CLICK_ROW_COL" is not allowed.
Am I using the right event? Am I implementing it correctly?
Any help appreciated. Thanks in advance.
GillI chose to solve this by removing the line select buttons from the ALV and replacing them with a checkbox defined as a hotspot. I then used EVENT hotspot_click FROM cl_gui_alv_grid to highlight the line and change my totals on a single click.
-
Adding a color to row of a alv grid using function modules
Can anybody clearly explains me how to add a color to a row to an alv grid using function module reuse_alv_grid_display.
thanks in advance
regards
anil.hi,
chk this ample pgm
report zxyz_0004
no standard page heading.
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
data: begin of imara occurs 0,
matnr type mara-matnr,
mtart type mara-mtart,
maktx type makt-maktx,
color_line(4) type c,
tcolor type slis_t_specialcol_alv, "cell
end of imara.
data: xcolor type slis_specialcol_alv.
start-of-selection.
perform get_data.
perform write_report.
Get_Data
form get_data.
imara-matnr = 'ABC'.
imara-mtart = 'ZCFG'.
imara-maktx = 'This is description for ABC'.
append imara.
imara-matnr = 'DEF'.
imara-mtart = 'ZCFG'.
imara-maktx = 'This is description for DEF'.
append imara.
imara-matnr = 'GHI'.
imara-mtart = 'ZCFG'.
imara-maktx = 'This is description for GHI'.
append imara.
loop at imara.
if sy-tabix = 1.
imara-color_line = 'C410'. " color line
endif.
if sy-tabix = 2. "color CELL
clear xcolor.
xcolor-fieldname = 'MTART'.
xcolor-color-col = '3'.
xcolor-color-int = '1'. "Intensified on/off
xcolor-color-inv = '0'.
append xcolor to imara-tcolor.
endif.
modify imara.
endloop.
endform.
WRITE_REPORT
form write_report.
data: layout type slis_layout_alv.
layout-coltab_fieldname = 'TCOLOR'.
layout-info_fieldname = 'COLOR_LINE'.
perform build_field_catalog.
CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
is_layout = layout
it_fieldcat = fieldcat
tables
t_outtab = imara.
endform.
BUILD_FIELD_CATALOG
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
clear: fieldcat. refresh: fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Number'.
fc_tmp-fieldname = 'MATNR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '18'.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Type'.
fc_tmp-fieldname = 'MTART'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '4'.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material'.
fc_tmp-fieldname = 'MAKTX'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '40'.
fc_tmp-emphasize = 'C610'. " color column
append fc_tmp to fieldcat.
endform.
<b>anil , pls chk this link also.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
very hlpful.</b>
rgds
anver
<b>pls mark points if ur issue solved</b>
Message was edited by: Anversha s
Message was edited by: Anversha s -
How can I get the selected rows from two ALV grids at the same time?
I have a program that uses two ALV grids in one dialog screen. I'm using the OO ALV model (SALV* classes).
The user can select any number of rows from each grid. Then, when a toolbar pushbutton is pressed, I'd have to retrieve the selected rows from both grids and start some processing with these rows.
It is no problem to assign event handlers to both grids, and use the CL_SALV_TABLE->GET_SELECTIONS and CL_SALV_SELECTIONS->GET_SELECTED_ROWS methods to find out which rows were marked by the user. Trouble is, this only works when I raise an event in each grid separately, for instance via an own function that I added to the grid's toolbar. So, I can only see the selected rows of the same grid where such an event was raised.
If I try to do this in the PBO of the dialog screen (that contains the two grids), the result of CL_SALV_SELECTIONS->GET_SELECTED_ROWS will be empty, as the program does not recognize the marked entries in the grids. Also, an event for grid1 does not see the selected rows from grid2 either.
As it is right now, I can have an own button in both grid's toolbar, select the rows, click on the extra button in each grid (this will tell me what entries were selected per grid). Then, I'd have to click on a third button (the one in the dialog screen's toolbar), and process the selected rows from both grids.
How can I select the rows, then click on just one button, and process the marked entries from both grids?
Is it somehow possible to raise an event belonging to each grid programmatically, so that then the corresponding CL_SALV_SELECTIONS->GET_SELECTED_ROWS will work?
Thanks.Hello Tamas ,
If I try to do this in the PBO of the dialog screen (that contains the two grids), the result of CL_SALV_SELECTIONS->GET_SELECTED_ROWS will be empty, as the program does not recognize the marked entries in the grids. Also, an event for grid1 does not see the selected rows from grid2 either.--->
is it possible to have a check box in each grid & get the selected lines in PAI of the screen ?
regards
prabhu -
Get Row Data from a selected Row in an ALV Grid
Hello,
I create a Custom Control from an intern table. When i do a double click on a row, i call another dynpro. The data of the marked line should be written into an internal table.
How i implement this?
I tried things like:
Call method alv_list->GET_SELECTED_ROWS_BASE
or
Call method alv_list->GET_SELECTED_ROWSHi Sebastian,
For a double click event we need to register the double click event which goes the following way.
data: lref_alv type ref to cl_gui_alv_grid.
* after initializing ALV
SET HANDLER gref_application->handle_alv_dblclik FOR lref_alv.
Now this double click event needs to be handled in the local class.
eg:
CLASS lcl_application DEFINITION.
PUBLIC SECTION.
METHODS:
* Method to handle double click on ALV grid.............................
handle_alv_dblclik
FOR EVENT double_click
OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no.
endclass.
CLASS lcl_application IMPLEMENTATION.
* Method: HANDLE_ALV_DBLCLICK *
* Text: Event triggers when ALV grid is double clicked *
* -->e_row *
* -->e_column *
* -->es_row_no, *
METHOD handle_alv_dblclik.
data: lv_value(40) TYPE c.
* Get the value of the current cell double clicked......................
CALL METHOD gref_alv->get_current_cell
IMPORTING
e_value = lv_value
* here you can insert the values in the internal table
endmethod.
endclass.
hope this helps.
Regards,
Kinshuk -
I'm hoping that someone can help.
I have a program that displays an ALV grid. I want the user to be able to select one or more lines from this grid and then to pop up a box to allow them to input a new date and then update this date via BAPI.
Could any one please point me in the right direction of how to get the info of the lines selected by the user into another internal table so that I can merge this with my new date info to run the BAPI.
ThanksWhich version of ALV technology do you use (REUSE_ALV, OO ALV, SALV ? ) <br />
<br />
e.g. for CL_GUI_ALV_GRID<br />
- Use the <a class="jive-link-external" href="http://help.sap.com/saphelp_erp2004/helpdata/en/ef/a2e9eff88311d2b48d006094192fe3/frameset.htm" target="_newWindow">SEL_MODE</a> field of the layout to enable multiple row selection (also add a check box in internal table)<br />
- you have method <a class="jive-link-external" href="http://help.sap.com/saphelp_erp2004/helpdata/EN/0a/b55312d30911d2b467006094192fe3/frameset.htm" target="_newWindow">GET_SELECTED_ROWS</a> and CHECK_CHANGED_DATA <br />
<br />
<i>Also, don't hesitate to use the search tool.there are sample in wiki like [Capture single and multiple row selction in ALV |http://wiki.sdn.sap.com/wiki/display/Snippets/Capturesingleandmultiplerowselctionin+ALV]</i><br />
<br />
Regards,<br />
Raymond -
Single selection in ALV Grid Control
hi,
I want to enable single row selection only in the alv grid displayed.
attribute sel_mode of layout doesnt help.
Can anybody provide me a solution.
Regards,
AuroHello,
Try this:
DATA:gs_layout type lvc_s_layo.
gs_layout-NO_ROWMARK = 'X'.
call method g_grid->set_table_for_first_display
exporting is_layout = gs_layout
Regards,
Beejal
**reward if this helps -
How to disable the first row of an ALV Grid?
Hi All,
I am working on a module pool programme. I am displaying ALV grid. I have to give some default values in the first row and disable it. I have to disable the third column and fourth row value. How can i achieve this?
Help will be appreciated.
Thanks,
Ibrahim.here is the code i have written....but its not working...
TYPES : BEGIN OF tp_grid,
fname(25) TYPE c,
reqd,
seqno TYPE n,
tl_styl TYPE lvc_t_styl,
edit,
END OF tp_grid.
DATA : wl_styl TYPE lvc_s_styl.
DATA : wl_layout TYPE lvc_s_layo.
DATA : lt_celltab TYPE lvc_t_styl.
READ TABLE tl_grid INTO wl_grid INDEX 1.
wl_styl-fieldname = 'TAG NUMBER'.
wl_styl-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT wl_styl INTO TABLE lt_celltab.
INSERT LINES OF lt_celltab INTO wl_grid-tl_styl index 1.
MODIFY tl_grid INDEX 1 FROM wl_grid.
wl_layout-stylefname = 'TL_STYL'.
CALL METHOD l_initgrid->set_table_for_first_display
EXPORTING
is_layout = wl_layout
CHANGING
it_outtab = tl_grid
it_fieldcatalog = tl_init_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDFORM. " display_initgrid
Help will be appreciated....
Thanks,
Ibrahim -
Multi Line Selection with ALV Grid
Dear all
what do I have to do to make multiple line selection available in an ALV Grid (Version 4.7)?
HerbertHi Herbert again,
Once you displayed your alv output display, then select rows in the alv display.
then when you click for interactive buttion (ie. like Refresh functionality), In debug mode you can see internal table with Sell field active (i.e. marked "X") which you have selected.
e.g.
FORM user_command USING lv_ucomm TYPE sy-ucomm ls_selfield TYPE slis_selfield.
DATA:
lv_ref_grid TYPE REF TO cl_gui_alv_grid.
CLEAR : gv_tcode.
*-- to ensure that only new processed data is displayed
IF lv_ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lv_ref_grid.
ENDIF.
IF NOT lv_ref_grid IS INITIAL.
CALL METHOD lv_ref_grid->check_changed_data.
ENDIF.
CASE lv_ucomm.
WHEN '&IC1'.
IF ls_selfield-fieldname = 'MATNR'.
READ TABLE gt_gi INTO gs_gi INDEX ls_selfield-tabindex.
IF sy-subrc = 0.
gv_tcode = 'MMBE'.
SET PARAMETER ID 'MAT' FIELD gs_gi-matnr.
CALL TRANSACTION gv_tcode AND SKIP FIRST SCREEN. "#EC CI_CALLTA "MMBE
ENDIF.
ENDIF.
WHEN 'COPY'.
LOOP AT gt_gi INTO gs_gi WHERE sel = 'X'.
gs_gi-sel = ' '.
APPEND gs_gi TO gt_gi.
CLEAR gs_gi.
ENDLOOP.
WHEN 'POST'.
REFRESH : gt_error[].
WHEN OTHERS.
ENDCASE.
ENDFORM. " USER_COMMAND
I hope you clear now.
Feel free to ask any doubts.
Thanks and regards,
Vijay -
Sending the rows in an ALV grid chosen by the user to another report
Hello Experts!
I am facing a problem with respect to ALV grid using OOABAP.
I am displaying an ALV grid. The user selects a few rows from this grid and clicks on a button called "Update" which i have incorporated into the grid.
Once the user clicks on update, i should call another report passing only the rows selected by the user. I am using the method "get_selected_rows" do get the indices of the rows selected. But, i am unable to proceed from here. How do i incorporate this logic in my code? Can anyone give me some sample code?
Thanks and Regards,
SmithaHi Smitha
Get the rows of the ALV into an internal table . You are right in using the method GET_SELECTED_ROWS.
Suppose li_tab is the internal table in which you have the rows of ALV.
Write this statement in the report from which you are transporting.
EXPORT li_tab TO MEMORY ID sy-repid.
Write this statement in the report to which you are transporting.
IMPORT sel_tab = li_tab FROM MEMORY ID 'Z_Report_Name'.
hope it works.
Reward points if helpful.
Maybe you are looking for
-
Hello, I need some suggestions on what might be the best way to handle security in my application. The application acts as a control panel with an initial login screen. When a user logs in it needs to be given access to certain menus and buttons base
-
Satellite Pro C850-1M - upgrade to Win 8.1 fails - error 0xC1900101-0x30018
Hello to all, bought a new Sattelite Pro C850-1MX (PSCBZE 00M009GR) in december 2013. System is running almost unchanged to delivery state. Yet installed OpenOffice, Firefox and AdobeReader in most actual versions. And updated driver for AMD-GPU to l
-
Unable to install Creative Suite 5 Design Premium - Windows 7
The hard drive on my laptop is failing. I was able to actually uninstall Adobe’s Creative Suite 5.5 Design Premium. Now I am trying to install on my new laptop, a Toshiba Satellite S50-A running Windows 7. The processor is Intel® Core ™ i7-4700MQ C
-
Sun server - file not found warning message - send-file reports: HTTP4142
(File not found) [25/Sep/2012:17:37:34] warning ( 9732): for host 127.0.0.1 trying to GET /vt/css/body_ie8.css, send-file reports: HTTP4142: can't find C:/Program Files/Sun/WebServer7/https-AC7440R877W6X.com/web-app/AC7440R877W6X.com/vt/css/body_ie8.
-
How can I block a particular program and not the whole channel?
I want to block a particular program. When I am trying to that, it blocks whole channel. How can I do that? Second Q is: can I have two parental control pins to block programs?