cancel
Showing results for 
Search instead for 
Did you mean: 

Editable ALV

Former Member
0 Kudos

Hi experts,

I m looking for some tutorials/tips about the following :

I want to build an alv grid with 4 columns : The first columns is editable, but the other 3 not.

The first column : The first column contains pernr (personal nummera), wich uses of a data dictionary search help PERJM.

If the user selects a personal number, the other 3 columns will be filled based on that personal number.

The initial size of that alv will be 6 rows, but the user can always add extra rows to it.

Thanks in advance,

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

DATA : LO_CMP_USAGE           TYPE REF TO   IF_WD_COMPONENT_USAGE.
  DATA : LO_INTERFACECONTROLLER TYPE REF TO   IWCI_SALV_WD_TABLE.
  DATA : LO_CONFIG              TYPE REF TO   CL_SALV_WD_CONFIG_TABLE.
  DATA : LO_TABLE_SETTINGS      TYPE REF TO   IF_SALV_WD_TABLE_SETTINGS.
  DATA : LR_COLUMN_SETTINGS     TYPE REF TO   IF_SALV_WD_COLUMN_SETTINGS.
  DATA : LT_COLUMNS             TYPE          SALV_WD_T_COLUMN_REF.
  DATA : LS_COLUMNS             LIKE LINE OF  LT_COLUMNS.
  DATA : LR_DROPDOWN            TYPE REF TO   CL_SALV_WD_UIE_DROPDOWN_BY_KEY.
  DATA : LR_CHK                 TYPE REF TO   CL_SALV_WD_UIE_CHECKBOX.
  DATA : HR_COLUMN              TYPE REF TO   CL_SALV_WD_COLUMN_HEADER.
  DATA : LV_TEXT                TYPE          STRING.
*--------------------------------------------------------------------*
  " Get the component useage instance
  LO_CMP_USAGE = WD_THIS->WD_CPUSE_ALV_REQUEST_HEADER( ).  "ALV name in the component usage
  IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
    LO_CMP_USAGE->CREATE_COMPONENT( ).
  ENDIF.
*--------------------------------------------------------------------*
  " Get the interface controller instance
  LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV_REQUEST_HEADER( ).
  LO_CONFIG = LO_INTERFACECONTROLLER->GET_MODEL( ).

  IF LO_CONFIG IS NOT INITIAL.

    " to deactivate the sorting of the columns.
*    LO_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_SORT_HEADERCLICK_ALLOWED( ABAP_FALSE ).
    " To hide the View Dropdown option in the alv Toolbar.
    LO_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_VIEW_LIST_ALLOWED( ABAP_FALSE ).

    " To hide the filter option in the alv Toolbar.
    LO_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_FILTER_FILTERLINE_ALLOWED( ABAP_FALSE ).

    " To hide the settings option in the alv Toolbar.
    LO_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_DIALOG_SETTINGS_ALLOWED( ABAP_FALSE ).

    " To hide the AppendRow Push Button in the alv Toolbar.
    LO_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_APPEND_ROW_ALLOWED( ABAP_TRUE ).


    " To hide the Insert Row Push Button in the alv Toolbar.
    LO_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_INSERT_ROW_ALLOWED( ABAP_FALSE ).

    " To hide the Delete Row Push Button in the alv Toolbar.
    LO_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_DELETE_ROW_ALLOWED( ABAP_FALSE ).

    " To get the dropdowns displayed Need to set the table to editable by using below statement
    LO_CONFIG->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( ABAP_FALSE ).

endif.

This Code will help u to add append button so that it ll add row when u click on that button

2. create a event handler method for an event on cell action. it will trigger when u enter any thing in pernr (Employee No) and press enter their u can write ur respective code.

hope this will help u.

Thanks & Regards

Vasu Yadav

Former Member
0 Kudos

i try to make a column 'PERNR' editable , but the following code doesn t work .. i can't see what i m wrong doing :

Any help ?

* Creation of ALV usage

data lo_cmp_usage type ref to if_wd_component_usage.

lo_cmp_usage =   wd_this->wd_cpuse_alv( ).

if lo_cmp_usage->has_active_component( ) is initial.

   lo_cmp_usage->create_component( ).

endif.

* Getting the ALV model

DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .

lo_INTERFACECONTROLLER =   wd_this->wd_cpifc_alv( ).

DATA lv_value TYPE ref to cl_salv_wd_config_table.

   lv_value = lo_interfacecontroller->get_model( ).

* Change the ALV table width

CALL METHOD LV_value->if_salv_wd_table_settings~SET_WIDTH

   EXPORTING

     VALUE  = '1400'.

* Make ALV table editable

   lv_value->if_salv_wd_table_settings~set_read_only( abap_false ).

   "lv_value->if_salv_wd_table_settings~SET_CELL_ACTION_EVENT_ENABLED( abap_true ).

* Change the columns header text

Data : lt_fields type salv_wd_t_column_ref,

        ls_fields type salv_wd_s_column_ref,

        lo_header type ref to cl_salv_wd_column_header.

CALL METHOD LV_VALUE->if_salv_wd_column_settings~get_columns

   RECEIVING

     VALUE  = lt_fields.

loop at lt_fields into ls_fields.

   call method ls_fields-r_column->get_header

        receiving

           value = lo_header.

   lo_header->SET_PROP_DDIC_BINDING_FIELD(

        property = if_salv_wd_c_ddic_binding=>bind_prop_text

        value    = if_salv_wd_c_ddic_binding=>ddic_bind_none ).

   case ls_fields-id.

     when 'PERNR'.

        Data : lr_input type ref to cl_salv_wd_uie_input_field.

        create object lr_input exporting value_fieldname = 'PERNR'.

       

        ls_fields-r_column->set_cell_editor( lr_input ).

            

*       call method lo_header->SET_TEXT

*           EXPORTING

*             value = 'Personnel number'.

     when 'UNAME'.

*      call method lo_header->SET_TEXT

*           EXPORTING

*             value = 'User Id'.

       "ls_fields-r_column->set_visible( value = '00' ).

       

     when 'NAME'.

       call method lo_header->SET_TEXT

            EXPORTING

              value = 'Approver Name'.

     when 'FUNCTION'.

       call method lo_header->SET_TEXT

            EXPORTING

              value = 'Function'.

   endcase.

endloop.

Former Member
0 Kudos

i think u didn't have any data in the node which u bind to the ALV table.

if u have data then u can make that column to editable.

As of now u didnt have any data on ur node so please append a dummy record .

then write the code for editable.

in wd_do_init method

ls_table-pernr = '*'.

append ls_table to lt_table.

place ur code after this

hope u can achieve it.

Thanks & Regards

Vasu Yadav.

Former Member
0 Kudos

The above code works only if you try new row.

The problem is how to make the PERNR column editable even if the alv table is empty.

So i want to display the alv from wddoinit with 6 rows and PERNR is editable , so without using the add row button.

lv_value->if_salv_wd_table_settings~SET_VISIBLE_ROW_COUNT( 6 ).


Former Member
0 Kudos

Thanks Vasu .. that was the problem , is it possible to make the column editable even if the node is empty ?

so without that dummy data

Former Member
0 Kudos

with out data we cannot make that field to editable so first u can append dummy records to the table so that u can make them as editable...

for this type of requirement i append five records.

so that i have fifth rows in table where first field is in editable so that i provide input and press enter so that by using on cell action event i populated data .

after fifth row we have to use append row.

<-- Removed by Moderator -->

Thanks & Regards

Vasu Yadav

Former Member
0 Kudos

Actually no but I think as ur using PERNR by default it has 00000000 value so u can do with out star use just append ls_table to lt_table once so that u can made that to editable

But with out data we cannot made that to editable

Thanks &Regards

Vasu Yadav

Former Member
0 Kudos

i m wondering how to move an element up/down in the table : is there any standard functionality in the alv , or i have to build it self ...any tips ?

maybe using the method MOVE_ELEMENT (Interface 'IF_WD_CONTEXT_NODE') ?

Former Member
0 Kudos

you can use drag and drop functionality of alv .

or

if you want to change row number you can do first get all rows  internal table using GET_STATIC_ATTRIBUTE_TABLE of class IF_WD_CONTEXT_NODE then rearranging row in internal table.

after rearranging of rows in internal table you can again bind that internal table using method BIND_TABLE.

Former Member
0 Kudos

i tried to use the drag and drop functionality of the alv, but without good result.

i m use if_salv_wd_drag_and_drop with methods CREATE_DRAG_SOURCE_INFO and CREATE_DROP_ROW_TARGET_INFO

but it doesn;t trigger the event handler on_drop.

I think i miss the right parameters  in the above methods.

Alv : contains 4 column , column PERNR is an input field.

Any body some suggestions/tips ?

Thanks & Regards

Former Member
0 Kudos

Hi

i didn't get u

first tell me one thing u want to arrange column position or row position....?

Thanks & Regards

Vasu Yadav

Former Member
0 Kudos

Dear Vasu,

I m now talking about arranging row position .

Thanks

Former Member
0 Kudos

drag and drop functionality of ALV  work in NetWeaver 7.02.

if you are already in 7.02 or enh. pkg 2  then you have to create tags for both drag and drop source than on drag and drop will trigger event

Former Member
0 Kudos

i work in netweaver 7.02 .. if you can provide sample/code how to do it .. it will help me a lot

Thanks & Regards

Answers (2)

Answers (2)

gurunathkumar_dadamu
Active Contributor
0 Kudos

Hi,

while creating the alv,pass the EDIT = 'X' for which field you want to edit.so that you can edit entire column of the PERNR.

fieldcatalog-fieldname   = 'PERNR'.

  fieldcatalog-seltext_m   = 'Personal number'.

  fieldcatalog-edit               = 'X'.

  append fieldcatalog to fieldcatalog.

  clear  fieldcatalog.

Regards,

Gurunath Kumar D

Former Member
0 Kudos

My question is how to make the values of the 3 last columns depends on the value of the first column ?

which event i can use to achieve this ?

Former Member
0 Kudos

on_cell_action event you can use but after entering value you have to press enter