How to mark row in OO ALV ?
Hi ,
I am using OO editable ALV . Method set_table_for_first_display has been used . In the report, user can select a row /rows and click on button 'EDIT' in the toolbar . Then one pop up screen will be displayed where user can change the fields . The changed fields will be copied to original ALV output .
In order to reflect changes in the ALV ouput , I am using method refresh_table_display to refresh the ALV display . After refresh I am using method set_selected_rows to mark row/rows which were selected earlier but, the issue is that row/rows are not getting marked in the ALV output .
Any suggestions to mark row/rows after using method refresh_table_display to refresh the ALV display would be of helpful .
Thanks in advance .
HI,
it should be a field in ALV data table for select , for example CHK ( Character len 1 ) see bellow :
TYPES: BEGIN OF wa_out ,
CHK TYPE C LENGTH 1 ."MARK ROW
INCLUDE STRUCTURE ZPP_BARCODE .
TYPES : cellcolors TYPE lvc_t_scol ,
SERNR TYPE objk-SERNR ,
VORNR TYPE afru-VORNR ,
ROWNO TYPE i ,
end of wa_out.
you should update ALV data table with X or space in field CHK
data:
ET_INDEX_ROWS TYPE LVC_T_ROW ,
ET_ROW_NO TYPE LVC_T_ROID ,
wa_ROW_NO LIKE LINE OF ET_ROW_NO.
data: w_cellcolor TYPE lvc_s_scol. "For cell color
data: gt_out TYPE STANDARD TABLE OF wa_out , "ALV data table
wa_out1 type wa_out .
in layout table put CHK to BOX_FNAME field
ls_layout-edit = ''.
ls_layout-zebra = 'X'.
ls_layout-CWIDTH_OPT = 'X' .
ls_layout-BOX_FNAME = 'CHK' .
after user select ALV rows and before process
"----- call GET_SELECTED_ROWS to read selected rows:
CALL METHOD GI_GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = ET_INDEX_ROWS
ET_ROW_NO = ET_ROW_NO.
"------now modify ALV table :
LOOP AT ET_ROW_NO INTO wa_ROW_NO .
WA_OUT1-chk = 'X' .
MODIFY GT_out index wa_ROW_NO-ROW_ID FROM WA_OUT1 TRANSPORTING chk .
ENDLOOP.
now you can read selected rows from ALV
loop at gt_out into WA_OUT1 where CHK = 'X' .
endloop.
Regards ,
REZA ROSTAMI / MAPNA / ABAP
Similar Messages
-
How to handle marked rows in an ALV table
Hi Experts,
there is an ALV table in my Web Dynpro. It has a functionality to handle one marked row via lead selection. This is the coding to get the marked row:
lr_nd_ma_leist = wd_context->get_child_node( name = wd_this->wdctx_tab_ma_leist ).
lr_el_ma_leist = lr_nd_ma_leist->get_lead_selection( ).
idx = lr_el_ma_leist->get_index( ).
My problem is to handle more than one marked row. I changed the contexts' properties to allow to mark more than one row. But how can I get the number and the index of all the marked rows?
Thanks in advance,
Tanuse the method get_element_selected( ) and get_index( ).
data sel type WDR_CONTEXT_ELEMENT_SET.
sel = lo_nd_zdealer->get_selected_elements( INCLUDING_LEAD_SELECTION = abap_true ).
data el type ref to if_wd_context_element.
data indx type i.
loop at sel into el.
indx = el->get_index( ).
endloop.
thanks
sarbjeet singh -
How to capture row selection in ALV output List
Hi experts,
I am displaying some output using ALV function module. My requirement is i have to capture how much rows user has selected in the output list, based on this information i have to perform some actions.
Please help me
Regards,
SachinHi Sachin,
For this first you have to define a variable in your internal table of type c with length 1 and then while building the layout of the ALV, you have to pass this variable name to the layout field BOX_FIELDNAME.
Now when you select a particular row, then the corresponding field in your internal table willl be marked with X. So, for further processing, you can just loop through the table where 'BOX = 'X' and proceed.
For Example:
* Structure for output details
TYPES: BEGIN OF gs_output.
INCLUDE STRUCTURE zas_water_qlty_rep.
TYPES: selected(1) TYPE c,
END OF gs_output.
DATA: object_tab TYPE STANDARD TABLE OF gs_output.
CONSTANTS: lc_selected(8) TYPE c VALUE 'SELECTED'.
lw_layout-box_fieldname = lc_selected. "Field for checkbox
* Local workarea
DATA: lw_layout TYPE slis_layout_alv.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_buffer_active = gc_x
i_bypassing_buffer = gc_x
i_callback_program = lv_repid
i_callback_pf_status_set = g_form_set_pf_stat
i_callback_user_command = lc_uform
i_structure_name = lv_zas_water_qlty_rep
is_layout = lw_layout
it_fieldcat = g_fieldcat_tab[]
it_events = g_events_tab[]
it_event_exit = g_event_exit_tab[]
TABLES
t_outtab = p_object_tab
EXCEPTIONS
program_error = 1
OTHERS = 2.
Hope this helps.
Regards,
Phani. -
How to make Rows editable in ALV
Hello,
I show some Records in my ALV and Column PersonalNumber is noneditable.
and I have created Append Row Button. If I click on this Button, then new added PersonalNumber should
be editable and old PersonalNumbers should be noneditable. How can we realize that?
otherwise; How can we make some editable and some noneditable in ALV?
Thanks!
with my Best Regards
Beserithan MalabakanHi,
Try this code for Editable ALV.
DATA: LR_COLUMN_SETTINGS TYPE REF TO IF_SALV_WD_COLUMN_SETTINGS,
LR_INPUT_FIELD TYPE REF TO CL_SALV_WD_UIE_INPUT_FIELD.
LR_COLUMN_SETTINGS ?= L_VALUE.
LR_COLUMN = LR_COLUMN_SETTINGS->GET_COLUMN( 'Your Field' ).
CREATE OBJECT LR_INPUT_FIELD EXPORTING VALUE_FIELDNAME = 'Your Field'.
LR_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).
If any doubts let me know.
Thanks.
Edited by: Viji on Feb 28, 2008 12:14 PM -
How to mark first record by default in oo ALV
Hi Experts,
I am using OO ALV to display ALV Grid in Custom Container. How to mark the frst record by default in ALV Grid.!
Please help.
Thanks in Advance,
Regards,
PriyaHi.,
Using set_selected_rows() method you can achieve this.,
First Call ALV using o_grid->set_table_for_first_display
Then call o_grid->set_selected_rows " here o_grid is reference to cl_gui_alv_grid
You have to pass parameter index 1 to it_row_no.
Also you can pass the row numbers which you want to select by default .,
hope this helps u.,
Thanks & Regards,
Kiran -
How to merge rows with similar values in alv grid display in webdynpro
Hi experts,
i want to know about how to merge rows with similar values in alv grid display of webdynpro.grouping rows is possible in table display in webdynpro but i am not able to do row grouping in the alv grid display in webdynpro.
kindly suggest.
thanks ,
Anita.Hi Anita,
did you find a solution for this? I have opened a Thread, if you know the answer maybe you could help me out:
Is there an ALV function similar to the TABLE Row grouping?
Thanx in advanced!!!
Kind Regards,
Gerardo J -
How to Process event when select ALV mark ?
Hi.
The Screen have ALV data.
How to Process event when select ALV mark ?
Regards.
LY.EVENT
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events[]
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_events WITH KEY name = slis_ev_top_of_page
INTO it_events.
IF sy-subrc = 0.
MOVE t_formname_top_of_page TO it_events-form.
APPEND it_events.
ENDIF.
ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat
it_events = it_events[]
i_callback_program = sy-repid
is_layout = gs_layout
i_save = g_save
is_variant = gx_variant
TABLES
t_outtab = i_data[]. -
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 to preselect all rows before displaying ALV report
I would like to select all rows before sending ALV Grid Display. User then can unselect couple of rows for further processing. How do I do that ?. Im using Method grid1->SET_TABLE_FOR_FIRST_DISPLAY for ALV Report Display. Any help appreciated.
Ok,
I've started the editor and check my code. I made few small mistakes (like with this exporting/importing), here's the sample - correctly working - code:
DATA: it_selected TYPE lvc_t_row,
wa_selected TYPE lvc_s_row,
wa_sflight TYPE sflight,
ltp_layout TYPE lvc_s_layo.
SELECT *
FROM sflight
INTO TABLE gi_sflight.
ltp_layout-stylefname = 'CELLTAB'.
ltp_layout-sel_mode = 'A'.
LOOP AT gi_sflight INTO wa_sflight.
wa_selected-index = sy-tabix.
APPEND wa_selected TO it_selected.
ENDLOOP.
* * Load data into the grid and display them
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = ltp_layout
i_save = 'A'
CHANGING it_outtab = gi_sflight.
CALL METHOD go_grid->set_selected_rows
EXPORTING
it_index_rows = it_selected.
This time it is 100% correct.
Edited by: Marcin Cudo on Apr 11, 2010 2:13 AM -
sir,
explain me how to edit row in alv report in particular column.put in the fieldcatalog;;
wa_fieldcat-edit = 'X'.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat. -
How to get row of the selected cell in ALV while implementing OVS
Dear Folks,
I am implementing OVS search help in ALV.When i click on cell, i can see the search help in cell and now i can identify the colomn of the cell but i can't identify the row of the cell.Can any one tell me how to identify row of the cell in this case.
Nirad.Thnx for the answer nithya.I have solved problem my self.
DATA: elem_ovs TYPE REF TO if_wd_context_element,
ls_data TYPE REF TO data,
ls_index type string.
FIELD-SYMBOLS : <ovs_data> TYPE data.
elem_ovs = ovs_callback_object->context_element.
ls_data = elem_ovs->get_static_attributes_ref( ).
ls_index = elem_ovs->GET_INDEX( ).
and this is the solution. -
How to Hide rows in ALV without affecting total sum at the end of table?
Hi,
I need some help in hiding particular rows in an ALV Grid without affecting the total sum at the end of the table. I am trying to hide the rows that have negative quantities, but I still need those values so that the user can still compute for the total sums. Can anyone help? Thanks.
JosephHi,
Hopw this way you can hide the rows in the GRID.
DATA:
ld_column TYPE lvc_fname,
ld_hide TYPE abap_bool.
FIELD-SYMBOLS:
<ls_entry> TYPE any,
<ld_fld> TYPE any.
ld_column = 'COL_1'. " column which you want to suppress if everything is zero
ld_hide = abap_true. " = 'X'; default hide column
LOOP at <gt_outtab> ASSIGNING <ls_entry>.
ASSIGN COMPONENT (ld_column) OF STRUCTURE <ls_entry> TO <ld_fld>.
IF ( <ld_fld> > 0 ).
ld_hide = abap_false. " display column because at least single value > 0
EXIT. " leave LOOP
ENDIF.
ENDLOOP.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = ld_column.
IF ( syst-subrc = 0 ).
ls_fcat-no_out = ld_hide.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDIF.
hop you will get the total with for those columns too.
Regards,
Madhavi -
How to make rows editable of a dynamic ALV
Hi All,
I'm displaying a dynamic internal table on an ALV.
The probelm is that some of the rows of that ALV should be editable.
I checked some of the forums, where I got a clue that I have to update this LVC_S_STYL structure for this requirement.
I populated this structure also. But still that ALV is coming as non-editable.
Kindly help me out in resolving this issue.
Thanks and Regards,
AbhijeetCheck this article [Easy Reference to ALV |http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907]. I am sure, you will find the solution here.
-
How to realize this kind of ALV(with two headerlines)?
Dear all:
could anyony provide some advice on how to realize this kind of ALV?
|--|--
field2
|--|||--
field11 | field12 | field21 | field212 |
|--|||--
wait your kindly adviceI had similar kind of requirement. Have a look at below code. It will help you. You can execute it. You can see the report output which contains two header lines.
REPORT ztestvib MESSAGE-ID zz LINE-SIZE 50.
TYPE-POOLS: slis.
DATA: x_fieldcat TYPE slis_fieldcat_alv,
it_fieldcat TYPE slis_t_fieldcat_alv,
l_layout TYPE slis_layout_alv,
x_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
DATA: BEGIN OF itab OCCURS 0,
vbeln LIKE vbak-vbeln,
posnr LIKE vbap-posnr,
male TYPE i,
female TYPE i,
END OF itab.
SELECT vbeln
posnr
FROM vbap
UP TO 20 ROWS
INTO TABLE itab.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'MALE'.
x_fieldcat-seltext_l = 'MALE'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'FEMALE'.
x_fieldcat-seltext_l = 'FEMALE'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_events-name = slis_ev_top_of_page.
x_events-form = 'TOP_OF_PAGE'.
APPEND x_events TO it_events.
CLEAR x_events .
l_layout-no_colhead = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = l_layout
it_fieldcat = it_fieldcat
it_events = it_events
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*& Form top_of_page
text
FORM top_of_page.
*-To display the headers for main list
FORMAT COLOR COL_HEADING.
WRITE: / sy-uline(103).
WRITE: / sy-vline,
(8) ' ' ,
sy-vline,
(8) ' ' ,
sy-vline,
(19) '***'(015) CENTERED,
sy-vline.
WRITE: / sy-vline,
(8) 'VBELN'(013) ,
sy-vline,
(8) 'POSNR'(014) ,
sy-vline,
(8) 'MALE'(016) ,
sy-vline,
(8) 'FMALE'(017) ,
sy-vline.
FORMAT COLOR OFF.
ENDFORM. "top_of_page
The header lines are as below:
VBELN POSNR MALE FMALE
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers -
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
Maybe you are looking for
-
How can I copy my contacts on my ios to my email
I have a new email and I want all the conacts on my iCloud to be copyed in to the email I`m using an iPhone 4 & iPad 3 all updated to 6.1
-
when i run the following query i getbthe error invalid column name .My db oracle 8i,NT. rs8 = stmt2.executeQuery("select a.c_x12n_position_cd, a.c_x12n_sequence_cd, a.c_x12n_composite_id, " + "a.c_x12n_table_area_cd, a.c_x12n_requirement_cd, a.c_x12n
-
using Windows 7 with i3 processor all the latest updates. Firefox is the ONLY browser that gives me this problem. I should not have to turn off my antivirus or go into my config files, write code or anything to have this simple task to work. If I buy
-
Custom Function in SAP MDM Data Manager Validation
Hi SDN, Can we write our own custom function for Validation of the records. Actually my requirment is For a particular Account Group The value of the G/L Account must be in particular range and it must have a specific Length. For Example: IF( Chart
-
How can I see how is in the homesharing?
I'm trying to connect a iMac to Homesharing at my home. But when I try, I get the message that the limit(max 5 computers in Homesharing) is reached.