Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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,

Vinod

Not what you were looking for? View more on this topic or Ask a question