How to Edit selected row in ALV
Hi Experts,
I new to webdynpro ABAP. How to Edit the entire selected row in ALV. Please suggest?
Thanks in advance.
Hi,
I guess you have created the node as dynamic and also set this to the ALV..
1. Have you created READ_ONLY attribute of type wdy_boolean inside the node to which the ALV is bound..If not create it first and set the default value for this readonly as abap_true...ie X.
2. Got the contents in the internal table.
bind the table to the node..
3.Instantiate the ALV.
4. Now get teh column refrences of this ALV using the cl_salv_wd_config_table..and for columns
use the cell editor type as cl_salv_wd_uie_input_field...
loop through the column references and for all refrences create an object of type Input field and inside this class
use the method set_read_only_field_name ( 'READ_ONLY' ).
For the table settings if_salv_wd_table_settings of cl_salv_wd-config_table.. set the read only mode as abap_false..
5 create the custom button in the ALV using the cl_salv_wd_fe_button..
6 In this go for the events ON_FUCNTION and inside this method..do the coding
7 .Initially the table will be set to non editable..
In the button handler....
Get the refernece of this node to which the ALV is bound.....
lr_node = wd_context->get_child_node( 'VBAK' ). "dynamic node name
lv_index = lr_node->get_lead_selection_index ( ).
loop at it_table into ls_table.
if sy-tabix eq lv_index.
ls_table-read_only = abap_false. "editable
else.
ls_table-read_only = abap_true. "non editable
endif.
modify table
endloop.
lr_node->bind_table( lt_table ).
If you have any doutbs just refer the previous thread posted on the same..
You can follow the above steps to acheive thjs..
Regards,
Lekha.
Edited by: Lekha on Dec 17, 2009 6:10 PM
Similar Messages
-
How To Edit Selected Row In ALV Table
Hello Experts,
In My Webdynpro Application, I am displaying records from database table into an ALV Table.
I want to edit only selected record from ALV table.
Please Suggest How to achieve this.
Thanks,
PratibhaThe link given above is for the UI element 'Table' and does not pertain to ALV.
To Make an ALV Editable on lead selection for that particular lead selected row.
1. The ALV should be made lead selectable, when initializing
2. The ON_LEAD_SELECT function should be invoked.
3. Withing this function the index has to be retrieved to know which row was selected.
4. Based on the index retrived all the columns have to pass FALSE to read_only in the column properties.
Regards,
Pramod -
How to edit selected rows in a datagrid?
Hi all,
I am new to flex and I would like to know how to edit
selected rows( through check boxes) in a data grid. As of now the
whole data grid becomes editable.
Regards
Saran.This is not simple in Flex 2.0.
You will need to use a custom itemRenderer.
Search the net, perhaps someone has a component or sample
close to what you want.
Tracy -
How to set selected row in alv display?
Hi,
How do I select some particular row in alv - say at first display i want to highlight 4th row. How can i do that?
Thanks,
Sheeltry to use method set_selected_rows just after method for first display.
-
How to get column value of a selected row of ALV
Hello ,
I have application POWL POWL_UI_COMP uses another component POWL_TABLE_COMP.
This POWL_TABLE_COMP uses SALV_WD_TABLE.
I want to select value of ORDER id and it need to be passed whenever user selects a display order button(Which is self defined function generated in POWL_TABLE_COMP) . I am calling a display order on action of this display button(http://nap60.nalco.one.net:8042/sap/bc/webdynpro/sap/mt_order_app?IV_ACTIVITYTYPE=A&IV_EQUIPMENT=aaaa&IV_ORDERID=90001511&IV_ORDERTYPE=STD&IV_QMNUM=00&IV_TPLNR=00)
ORDERID is one column value of selected row of ALV table.
So please can you suggest , how to read ORDERID and pass it to the self defined function..
thanks in advance,
SharadaAnoop,
I have plcaed this code in event handler of on_lead_select.
Its giving error the element doesnt exist.
static_attributes should give me row data but it's giving short dump saying
Pl can you suggest.
data: set_of_element type WDR_CONTEXT_ELEMENT_SET,
element1 type ref to IF_WD_CONTEXT_ELEMENT,
result type POWL_CRESULT_STY,
table_helper type ref to CL_POWL_TABLE_HELPER,
context_node type ref to IF_WD_CONTEXT_NODE,
lt_selected_elements TYPE wdr_context_element_set,
static_attributes type ref to data.
table_helper = wd_comp_controller->mr_table_helper.
context_node = table_helper->get_data_node( ).
context_node = wd_comp_controller->mr_table_helper->get_data_node( ).
context_node->get_static_attributes( exporting index = r_param->index
importing static_attributes = static_attributes ).
thanks,
Sharada -
HOW CAN I HAVE THE NUMBER OF SELECTED ROWS IN ALV GRID?
HI.
HOW CAN I HAVE THE NUMBER OF SELECTED ROWS IN ALV GRID????
GABRY =)You need to use
data : grid1 type ref to cl_gui_alv_grid.
call method grid1->get_selected_rows
importing
et_index_rows = i_sel_alvrows[].
a® -
How to get selected row index of a Table ?
hi gurus,I'm new to Webdynpro for abap
I'm displaying just Flight details in a Table so
how to get selected row index of a Table and need to be display in Message manager.Hi,
For getting the row index use the following code.
DATA lo_nd_node TYPE REF TO if_wd_context_node.
DATA lo_el_node TYPE REF TO if_wd_context_element.
DATA index TYPE i.
* navigate from <CONTEXT> to <NODE> via lead selection
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
lo_el_node = lo_nd_node->get_lead_selection( ).
index = lo_el_node->get_index( ).
node is the name of the node which is binded to the table.
For printing the message u can use code wizard.
Press ctrl-F7. Now Select generate message.
IN this select the method REPORT_SUCCESS
In the code now u can give index to Message text Exporting parameter. Comment receiving parameter.
Write the whole code in onLeadSelect of the table.
Regards,
Pankaj Aggarwal -
How to get selected row keys from RichSelectManyCheckbox
Adf Table has getSelectedRowKeys but SelectManyChekcbox does not has anything similar. Can you tell me how to get selected row keys programmatically for RichSelectManyCheckbox?
Hi User,
selectManyCheckbox component's value property holds the selected items values. Bind this property to some bean variable(of type list) so that you can get the selected values by accessing the bean property.
Sireesha -
How to set some rows in ALV to be editable or some non editable.
Dear all Gurus,
I'm facing a situation here, I need your assistance.
I'm creating a alv table where the user can enter a data and then this will be uploaded into the system. Now upon validation some records might fail and would need some changes and some records that had no problems would have been successfully posted.
When the program returns to the user i want the successful one's to be greyed out and not editable. I'm not sure on how i could acess the rows of the table. I tried few classes and an all i could manage was to change the table setting and configs.
Below i've pasted the code on how i've code my alv table. Please advice on how i could access the rows and disable the successfull ones. Please.
METHOD wddoinit .
DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage,
l_interface TYPE REF TO iwci_salv_wd_table,
l_model TYPE ref to cl_salv_wd_config_table, "Contains all characteristics of a table(collumns, fields, etc)
lt_columns TYPE salv_wd_t_column_ref, " Table type
lt_fields TYPE salv_wd_t_field_ref, " Table type
l_btn_ins TYPE REF TO cl_salv_wd_fe_button,
l_btn_del TYPE REF TO cl_salv_wd_fe_button,
l_btn_sell_all TYPE REF TO cl_salv_wd_fe_button,
l_btn_dell_all TYPE REF TO cl_salv_wd_fe_button,
l_btn_calc TYPE REF TO cl_salv_wd_fe_button,
l_btn_save TYPE REF TO cl_salv_wd_fe_button,
l_function TYPE REF TO cl_salv_wd_function,
l_column TYPE REF TO cl_salv_wd_column,
l_header TYPE REF TO cl_salv_wd_column_header,
lr_input_1 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_2 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_3 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_4 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_5 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_6 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_7 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_8 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_9 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_10 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_11 TYPE REF TO cl_salv_wd_uie_input_field,
lr_input_12 TYPE REF TO cl_salv_wd_uie_input_field,
l_link TYPE REF TO cl_salv_wd_uie_button.
CONSTANTS:
zzto TYPE string VALUE 'ZZTO',
zzfrom TYPE string VALUE 'ZZFROM',
takeoff_date TYPE string VALUE 'TAKEOFF_DATE',
read_date TYPE string VALUE 'READ_DATE',
takeoff_time TYPE string VALUE 'TAKEOFF_TIME',
read_time TYPE string VALUE 'READ_TIME',
ac_hrs TYPE string VALUE 'AC_HRS',
le_hrs TYPE string VALUE 'LE_HRS',
re_hrs TYPE string VALUE 'RE_HRS',
ac_cycle TYPE string VALUE 'AC_CYCLE',
re_cycle TYPE string VALUE 'RE_CYCLE',
le_cycle TYPE string VALUE 'LE_CYCLE',
ltext TYPE string VALUE 'LTEXT'.
l_ref_cmp_usage = wd_this->wd_cpuse_multi_alv( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage->create_component( ).
ENDIF.
*Map the interface.
l_interface = wd_this->wd_cpifc_multi_alv( ).
DATA:
node_mdoc TYPE REF TO if_wd_context_node,
elem_mdoc TYPE REF TO if_wd_context_element.
navigate from <CONTEXT> to <MDOC> via lead selection
node_mdoc = wd_context->get_child_node( name = if_create_mass_entry=>wdctx_mdoc ).
l_interface->set_data( r_node_data = node_mdoc ).
*Map the model
wd_this->l_model = l_interface->get_model( ).
*Map the columns
lt_columns = wd_this->l_model->if_salv_wd_column_settings~t_columns.
*Map the fields
lt_fields = wd_this->l_model->if_salv_wd_field_settings~t_fields.
cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all(
EXPORTING r_model = wd_this->l_model
allowed = abap_false ). " try abap_true
*Enable or Disable the ALV desired outlook and design
wd_this->l_model->if_salv_wd_table_settings~delete_header( ).
wd_this->l_model->if_salv_wd_table_settings~set_selection_mode(
value = cl_wd_table=>e_selection_mode-auto ).
wd_this->l_model->if_salv_wd_table_settings~set_width( value = '100%' ).
wd_this->l_model->if_salv_wd_table_settings~set_visible_row_count( value = '10' ).
wd_this->l_model->if_salv_wd_table_settings~set_read_only( value = abap_false ).
wd_this->l_model->if_salv_wd_std_functions~set_filter_filterline_allowed( value = abap_true ).
wd_this->l_model->if_salv_wd_std_functions~set_sort_headerclick_allowed( value = abap_true ).
wd_this->l_model->if_salv_wd_std_functions~set_export_allowed( value = abap_false ).
*Adding functionalities to the ALV
*'Insert Row' Button
CREATE OBJECT l_btn_ins.
l_btn_ins->set_text( 'Insert Row' ).
l_btn_ins->set_tooltip( 'To enter a new row' ).
l_btn_ins->set_image_source( value = 'ICON_INSERT_ROW' ).
l_function = wd_this->l_model->if_salv_wd_function_settings~create_function( id = 'INSERT' ).
l_function->set_position( value = '1' ).
l_function->set_editor( value = l_btn_ins ).
*'Delete Row' Button
CREATE OBJECT l_btn_del.
l_btn_del->set_text( 'Delete Row' ).
l_btn_del->set_tooltip( 'Delete the selected row' ).
l_btn_del->set_image_source( value = 'ICON_DELETE_ROW' ).
l_function = wd_this->l_model->if_salv_wd_function_settings~create_function( id = 'DELETE' ).
l_function->set_position( value = '2' ).
l_function->set_editor( value = l_btn_del ).
*'Select All' Button
CREATE OBJECT l_btn_sell_all.
l_btn_sell_all->set_text( 'Select All' ).
l_btn_sell_all->set_tooltip( 'Select all entered record' ).
l_btn_sell_all->set_image_source( value = 'ICON_INSERT_ROW' ).
l_function = wd_this->l_model->if_salv_wd_function_settings~create_function( id = 'SELECT' ).
l_function->set_position( value = '3' ).
l_function->set_editor( value = l_btn_sell_all ).
*'Deselect All' Button
CREATE OBJECT l_btn_dell_all.
l_btn_dell_all->set_text( 'Deselect All' ).
l_btn_dell_all->set_tooltip( 'Deselect all records selected' ).
l_btn_dell_all->set_image_source( value = 'ICON_DESELECT_ALL' ).
l_function = wd_this->l_model->if_salv_wd_function_settings~create_function( id = 'DESELECT' ).
l_function->set_position( value = '4' ).
l_function->set_editor( value = l_btn_dell_all ).
*'Calculate' Button
CREATE OBJECT l_btn_calc.
l_btn_calc->set_text( 'Calculate Hours' ).
l_btn_calc->set_tooltip( 'Calculate hours of each record' ).
l_btn_calc->set_image_source( value = 'ICON_CALCULATION' ).
l_function = wd_this->l_model->if_salv_wd_function_settings~create_function( id = 'CALC' ).
l_function->set_position( value = '5' ).
l_function->set_editor( value = l_btn_calc ).
*'Save' Button
CREATE OBJECT l_btn_save.
l_btn_save->set_text( 'Save All' ).
l_btn_save->set_tooltip( 'Save all' ).
l_btn_save->set_image_source( value = 'ICON_SYSTEM_SAVE' ).
l_function = wd_this->l_model->if_salv_wd_function_settings~create_function( id = 'SAVE' ).
l_function->set_position( value = '6' ).
l_function->set_editor( value = l_btn_save ).
FIELD-SYMBOLS: <fs_column> TYPE salv_wd_s_column_ref.
LOOP AT lt_columns ASSIGNING <fs_column>.
l_column = <fs_column>-r_column.
l_column->get_header( RECEIVING value = l_header ).
l_header->set_ddic_binding_field( value = if_salv_wd_c_column_settings=>ddic_bind_none ).
CASE <fs_column>-id .
WHEN zzfrom.
CREATE OBJECT lr_input_1 EXPORTING value_fieldname = zzfrom.
l_header->set_text( value = 'Flt Fr' ).
l_column->set_position( value = '1' ).
l_column->set_cell_editor( lr_input_1 ).
l_column->set_visible( '0' ).
WHEN zzto.
CREATE OBJECT lr_input_2 EXPORTING value_fieldname = zzto.
l_header->set_text( value = 'Flt To' ).
l_column->set_position( value = '2' ).
l_column->set_cell_editor( lr_input_2 ).
WHEN takeoff_date.
CREATE OBJECT lr_input_3 EXPORTING value_fieldname = takeoff_date.
l_header->set_text( value = 'Takeoff Date' ).
l_column->set_position( value = '3' ).
l_column->set_cell_editor( lr_input_3 ).
WHEN read_date.
CREATE OBJECT lr_input_4 EXPORTING value_fieldname = read_date.
l_header->set_text( value = 'Landing Date' ).
l_column->set_position( value = '4' ).
l_column->set_cell_editor( lr_input_4 ).
WHEN takeoff_time.
CREATE OBJECT lr_input_5 EXPORTING value_fieldname = takeoff_time.
l_header->set_text( value = 'Takeoff Time' ).
l_column->set_position( value = '5' ).
l_column->set_cell_editor( lr_input_5 ).
WHEN read_time.
CREATE OBJECT lr_input_6 EXPORTING value_fieldname = read_time.
l_header->set_text( value = 'Landing Time' ).
l_column->set_position( value = '6' ).
l_column->set_cell_editor( lr_input_6 ).
WHEN ac_hrs.
CREATE OBJECT lr_input_7 EXPORTING value_fieldname = ac_hrs.
l_header->set_text( value = 'Flt Time' ).
l_column->set_position( value = '7' ).
l_column->set_cell_editor( lr_input_7 ).
WHEN le_hrs.
CREATE OBJECT lr_input_8 EXPORTING value_fieldname = le_hrs.
l_header->set_text( value = 'LH Eng Runtime' ).
l_column->set_position( value = '8' ).
l_column->set_cell_editor( lr_input_8 ).
WHEN re_hrs.
CREATE OBJECT lr_input_9 EXPORTING value_fieldname = re_hrs.
l_header->set_text( value = 'RH Eng Runtime' ).
l_column->set_position( value = '9' ).
l_column->set_cell_editor( lr_input_9 ).
WHEN ac_cycle.
CREATE OBJECT lr_input_10 EXPORTING value_fieldname = ac_cycle.
l_header->set_text( value = 'No. of Landings' ).
l_column->set_position( value = '10' ).
l_column->set_cell_editor( lr_input_10 ).
WHEN re_cycle.
CREATE OBJECT lr_input_11 EXPORTING value_fieldname = re_cycle.
l_header->set_text( value = 'RH Eng Start' ).
l_column->set_position( value = '11' ).
l_column->set_cell_editor( lr_input_11 ).
WHEN le_cycle.
CREATE OBJECT lr_input_12 EXPORTING value_fieldname = le_cycle.
l_header->set_text( value = 'LH Eng Start' ).
l_column->set_position( value = '12' ).
l_column->set_cell_editor( lr_input_12 ).
WHEN ltext.
CREATE OBJECT l_link.
l_link->set_image_source( value = 'ICON_CREATE_TEXT' ).
l_link->set_text_fieldname( ltext ).
l_link->set_tooltip( value = 'Create Log' ).
l_header->set_text( value = 'Enter Log').
l_column->set_cell_editor( l_link ).
l_column->set_h_align( cl_wd_table_column=>e_h_align-center ).
l_column->set_position( value = '13' ).
WHEN OTHERS.
l_column->set_visible( '01' ).
ENDCASE.
ENDLOOP.
ENDMETHOD.
Your any help is highly appreciated. Thank you.
Regards,
VinodOk, here you go.
In your context, apart from your display fields, add another attribute READ_ONLY, type char01. And lets assume you want the field by name field_1 to be editable or not based on some validation. Your code will be like this to initialize the ALV.
DATA:
l_alv_model TYPE REF TO cl_salv_wd_config_table,
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_column TYPE REF TO cl_salv_wd_column,
lt_col TYPE SALV_WD_T_COLUMN_REF,
ls_col TYPE SALV_WD_S_COLUMN_REF,
lr_input_field type ref to cl_salv_wd_uie_input_field.
l_alv_model = l_ref_interfacecontroller->get_model( ).
l_alv_model->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( abap_false ).
lr_column_settings ?= l_alv_model.
lt_col = lr_column_settings->get_columns( ).
LOOP AT lt_col INTO ls_col where ID = 'FIELD_1'.
create object lr_input_field exporting value_fieldname = ls_col-id.
lr_input_field->set_read_only_fieldname( 'READ_ONLY' ).
ls_col-r_column->set_cell_editor( lr_input_field ).
ENDLOOP.
In your event handler, you read your node, do a get_static_attributes_table. Perform all validations. Loop through your internal table and set the field READ_ONLY as 'X' when validation succeeds. Do READ_ONLY = space when validation fails. Then do a bind_elements. Now the rows for which read_only is false, will be editable and vice versa.
Hope I was clear enough. Get back if you have any doubts.
Regards,
Nithya -
ALV - How to set selected rows into internal table
Hi all,
I am tying to set with an 'X' flag the selected rows in my ALV using an internal table that contains all rows showed.
More exactly I have tried to follow these steps.
1) I have added the filed SEL (type SEL) to my ALV structure zrt_bo_slabsend and I defined my internal table in this way
DATA: gt_report TYPE STANDARD TABLE OF zrt_bo_slabsend,
gw_report TYPE zrt_bo_slabsend.
2) I have set gw_layo-box_fname = 'SEL' to gw_layo (ALV layout)
Pressing the "delete button" that I have insert on the top of the ALV, I intercept correctly my user command and I call a form (named "delete_lines") where I have this abap code
FORM delete_lines.
DATA: l_subrc LIKE sy-subrc,
lw_grid_settings LIKE lvc_s_glay.
gw_layo-box_fname = 'SEL'.
"set field name to store row selection
gw_layo-edit = 'X'. "makes whole ALV table editable
gw_layo-zebra = 'X'.
gv_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY_LVC'
exporting
i_callback_program = gv_repid
i_callback_pf_status_set = gc_status
i_callback_user_command = gc_user_command
is_layout_lvc = gw_layo
it_fieldcat_lvc = gw_fkat
i_grid_settings = lw_grid_settings
i_save = 'X'
is_variant = variant
it_events = gt_events
TABLES
t_outtab = gt_report
EXCEPTIONS
program_error = 1
OTHERS = 2.
LOOP AT gt_report ASSIGNING <report> WHERE SEL = 'X'.
DELETE gt_report.
ENDLOOP.
ENDFORM.
I'd like to select many rows in my ALV report, than by pressing the delete button I'd like to see a refresh of my ALV, without the selected rows. I want to save it only at the end of my action, only by pressing the save button.
Any suggestion about the abap code will be well appreciated.
Thanks in advance for your kind help.
Regards.
GiovanniHi Giovanni,
I am using the method:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
I_CALLBACK_PROGRAM = gd_REPID
I_CALLBACK_PF_STATUS_SET = 'UDIT'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Mainatin cell entry'
* I_GRID_SETTINGS =
IS_LAYOUT_LVC = GS_LAYOUT
IT_FIELDCAT_LVC = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS_LVC =
* IT_SORT_LVC =
* IT_FILTER_LVC =
* IT_HYPERLINK =
* IS_SEL_HIDE =
I_DEFAULT = 'X'
* I_SAVE = 'X'
* IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
* IS_PRINT_LVC =
* IS_REPREP_ID_LVC =
I_SCREEN_START_COLUMN = 30
I_SCREEN_START_LINE = 14
I_SCREEN_END_COLUMN = 120
I_SCREEN_END_LINE = 25
* IT_EXCEPT_QINFO_LVC =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_ZCP_DEMAND_SYS1
* 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.
I have made five buttons on my toolbar (add, delete, save, back, exit).
Kindly tell me how can I catch the sy-ucomm of these buttons.
NOTE: this FM is written inside an user-exit, so I cannot make forms.
Thanks in advance. -
How to detect a selected row in ALV GRID
Hi,
Can anyone tell me how to detect and catch an event when a row is selected in an ALV GRID?
I would like to catch such event when the end user presses Ctrl + Shif + Space bar.
Thank you and best regards.
Hassane.Hi,
Use this wiki link, to have a checkbox with all the records in ALV Grid and to process those selected records at a user command, as per the requirement.
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alv%252bgrid%252bdisplay%252bwith%252bcheckbox%252bto%252bprocess%252bselected%252brecords%252bat%252bruntime
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir -
How to get selected rows in a new screen in alv.
Hi everybody,
I have a alv report in oops concept when i select a row all the details of that particular row should come in new screen.
can anybody help me regarding this if possible with example.
thanks in advance.
regards,
venu.Hi,
Check this.
select several rows in alv
It will be helpful.
Regards,
J.Jayanthi -
How to read output rows in alv
I have made alv grid. i have given checkbox for user to select the row.
so how to read the selected rows.hi
*REPORT YMS_ALVINTER.
*& tables declaration
TABLES: VBRK,VBRP.
*& type-pools declaration
TYPE-POOLS: SLIS.
*& data declaration
DATA: G_REPID TYPE SY-REPID.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "mara
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
WA_EVENT TYPE SLIS_ALV_EVENT,
T_EVENT TYPE SLIS_T_EVENT.
DATA: V_VBELN LIKE VBRK-VBELN,
V_MATNR LIKE VBRP-MATNR.
DATA: BEGIN OF IT_VBRK OCCURS 0,
VBELN LIKE VBRK-VBELN,
WAERK LIKE VBRK-WAERK,
VKORG LIKE VBRK-VKORG,
FKDAT LIKE VBRK-FKDAT,
BUKRS LIKE VBRK-BUKRS,
NETWR LIKE VBRK-NETWR,
END OF IT_VBRK.
DATA: BEGIN OF IT_VBRP OCCURS 0,
VBELN LIKE VBRP-VBELN,
POSNR LIKE VBRP-POSNR,
FKIMG LIKE VBRP-FKIMG,
VRKME LIKE VBRP-VRKME,
NETWR LIKE VBRP-NETWR,
MATNR LIKE VBRP-MATNR,
ARKTX LIKE VBRP-ARKTX,
END OF IT_VBRP.
*& selection screen
SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN,
S_FKDAT FOR VBRK-FKDAT,
S_MATNR FOR VBRP-MATNR.
SELECTION-SCREEN END OF BLOCK B.
**INITIALIZATION.
INITIALIZATION.
G_REPID = SY-REPID.
S_FKDAT-LOW = SY-DATUM - 200.
S_FKDAT-HIGH = SY-DATUM.
APPEND S_FKDAT.
***AT SELECTION-SCREEN.
AT SELECTION-SCREEN.
IF NOT S_VBELN IS INITIAL.
SELECT SINGLE VBELN FROM VBRK
INTO V_VBELN
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E001(ZZ2).
ENDIF.
ENDIF.
IF NOT S_MATNR IS INITIAL.
SELECT SINGLE MATNR FROM MARA
INTO V_MATNR
WHERE MATNR IN S_MATNR.
IF SY-SUBRC <> 0.
MESSAGE E001(ZZ2).
ENDIF.
ENDIF.
***START-OF-SELECTION.
START-OF-SELECTION.
PERFORM GET_DATA_VBRK.
*& Form GET_DATA_VBRK
text
--> p1 text
<-- p2 text
FORM GET_DATA_VBRK .
SELECT VBELN
WAERK
VKORG
FKDAT
BUKRS
NETWR
INTO TABLE IT_VBRK
FROM VBRK
WHERE VBELN IN S_VBELN
AND FKDAT IN S_FKDAT.
ENDFORM. " GET_DATA_VBRK
*& Form GET_DATA_VBRP
text
--> p1 text
<-- p2 text
FORM GET_DATA_VBRP .
SELECT VBELN
POSNR
FKIMG
VRKME
NETWR
MATNR
ARKTX
FROM VBRP
INTO TABLE IT_VBRP
WHERE VBELN = IT_VBRK-VBELN.
ENDFORM. " GET_DATA_VBRP
***END-OF-SELECTION.
END-OF-SELECTION.
PERFORM EVENT_LIST.
PERFORM GET_FIELD_CATALOG.
PERFORM LIST_DISP .
*& Form list_disp
text
FORM LIST_DISP .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = 'POPUP'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_VBRK
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.
ENDFORM. " LIST_DISP
*& Form GET_FIELD_CATALOG
text
--> p1 text
<-- p2 text
FORM GET_FIELD_CATALOG .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = G_REPID
I_INTERNAL_TABNAME = 'IT_VBRK'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = G_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GET_FIELD_CATALOG
*& Form event_list
text
--> p1 text
<-- p2 text
FORM EVENT_LIST .
CLEAR WA_EVENT.
WA_EVENT-NAME = 'USER_COMMAND'.
WA_EVENT-FORM = 'USER_COMMAND'.
APPEND WA_EVENT TO T_EVENT.
CLEAR WA_EVENT.
ENDFORM. " event_list
*& Form user_command
text
-->R_UCOMM text
-->RS_SELFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_VBRK INDEX RS_SELFIELD-TABINDEX.
PERFORM GET_DATA_VBRP.
PERFORM BUILD_FIELDCATALOG_VBRP .
PERFORM DISPLAY_ALV_VBRP.
ENDCASE.
ENDFORM. "user_command
*& Form BUILD_FIELDCATALOG_VBRP
text
--> p1 text
<-- p2 text
FORM BUILD_FIELDCATALOG_VBRP .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = G_REPID
I_INTERNAL_TABNAME = 'IT_VBRP'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = G_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " BUILD_FIELDCATALOG_VBRP
*& Form DISPLAY_ALV_VBRP
text
--> p1 text
<-- p2 text
FORM DISPLAY_ALV_VBRP .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_VBRP
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.
ENDFORM. " DISPLAY_ALV_VBRP
Message was edited by:
Rammohan Nagam
Message was edited by:
Rammohan Nagam -
How to find selected rows in REUSE_ALV_GRID_DISPLAY
HEllo All,
In OO we have a method to find get_selected_rows but i am unable to what is the way to find selected rows in REUSE_ALV_GRID_DISPLAY.
I am able to find a single row but i have to find multiple cleans in ALV. How can i do this.
Please help me with some ideas or please post some sample codes.
Regards,
LisaHi,
Check this code..
REPORT zdayatest1.
TABLES :t247.
TYPE-POOLS slis. "Type definitions for alv report
TYPES: BEGIN OF ty_func_tab,
fcode TYPE rsmpe-func,
END OF ty_func_tab.
DATA: it_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
DATA: is_lvc_s_glay TYPE lvc_s_glay.
DATA: wa_layout TYPE lvc_s_layo.
DATA: is_rxtab TYPE ty_func_tab.
DATA: BEGIN OF it_final OCCURS 0,
check(1),
mnr LIKE t247-mnr,
ltx LIKE t247-ltx,
END OF it_final.
DATA: wa_final LIKE it_final.
DATA: w_repid LIKE sy-repid.
START-OF-SELECTION.
w_repid = sy-repid.
REFRESH it_final.
SELECT mnr ltx
FROM t247
INTO CORRESPONDING FIELDS OF TABLE it_final
WHERE spras EQ 'E'.
wa_fieldcat-fieldname = 'CHECK'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-outputlen = '3'.
wa_fieldcat-col_pos = '1'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MNR'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-outputlen = '8'.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-coltext = 'Month'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LTX'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-outputlen = '20'.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-coltext = 'Month Desc'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = w_repid
i_callback_pf_status_set = 'SUB_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = 'TESTING'
is_layout_lvc = wa_layout
it_fieldcat_lvc = it_fieldcat
TABLES
t_outtab = it_final
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 USER_COMMAND
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
IF selfield-fieldname = 'CHECK'.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
LOOP AT it_final WHERE check = 'X'.
IF it_final-check IS INITIAL.
it_final-check = 'X'.
ELSE.
CLEAR it_final-check.
ENDIF.
MODIFY it_final.
ENDLOOP.
selfield-refresh = 'X'.
ENDIF.
ENDFORM. "USER_COMMAND
*& Form sub_pf_status
* text
* -->RT_EXTAB text
FORM sub_pf_status USING rt_extab TYPE slis_t_extab. "#EC CALLED
CLEAR is_rxtab.
is_rxtab-fcode = 'TEST'.
APPEND is_rxtab TO rt_extab.
SET PF-STATUS 'PF_STATUS' ."EXCLUDING rt_extab.
ENDFORM. "sub_pf_status -
How to hide selection column from alv grid
hi
i want to hide selection columns form alv grid.. how can i do it.. Is there any fm for that?
regards
palakHi,
the ALV Grid Control allows you to directly hide key columns with NO_OUT (field KEY_SEL is not used).
Field name:NO_OUT
Comp. type:LVC_NOOUT
Dtype(length):Char(1)
SPACE, 'X'
If you set this field, you hide the relevant column in the list. Nevertheless, the column is available in the field selection and can be interactively selected by the user as a display field. The ALV displays the contents of hidden fields on the detail screen for a row in the grid control.
Regards,
Neenu.
Edited by: Neenu Jose on Oct 21, 2008 10:46 AM
Maybe you are looking for
-
Where can I find the download link for Acrobat Standard v. 8.1 ?
where can I find the download link for Acrobat Standard v. 8.1 ? Thanks
-
HT4356 I've got the HP P1102w. Air Print
It worked fine with Air Print. After changing the password on our network, I can't reset the printer to the new password - as I can't find the settings for HTML anymore. Please help us! Thank you! John
-
UCCX 9 Web Chat Desktop Error.
Good day, All. I have UCCX 9 and Social Miner 9 newly installed. All traditional UCCX functinality works fine. But I'm not experienced in web-chat feature, so any advice is valueable. When I try to login to UCCX chat Desktop (through CAD buid-in brow
-
Copied some files over from a Parallels installation (mostly Word and Excel files) and apparently they were somehow tagged as hidden so they didn't show in the finder. I did the terminal script thing to make them show, BUT they are still not appearin
-
Is the NB550D compatible with windows 7 64-bit?
Hello I have install windows 7 64-bit on my NB550D but still in the computer properties --> system Type is saying 32-bit Operating System. Any ideas?