cancel
Showing results for 
Search instead for 
Did you mean: 

how to get Position of cursor and its cell value in webdynpro alv

former_member193460
Contributor
0 Kudos


Hi Experts,

     i have a requirement to get the position of cursor in webdynpro alv and get the value from that cell.

However, the value is not a changed value (we cant used on_data_check or on_cell_action as i dont have any button or link in the cell).

Please let me know how i can get the position of cursor in a alv , The alv event on_data_check, on_cell_action doesnt satisfy my requirement as i dont have any change of data and on_click cant be used as i dont have any link or button in the alv cells.

Please help.

Tashi Norbu

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member193460
Contributor
0 Kudos

Hi Experts,

     All the ALV events are triggered when there is a change of data.

Is there any way of getting position of the cursor in alv (after pressing enter key) if the data has not been changed ?

former_member222068
Active Participant
0 Kudos

Hi Tashi,

To check whether the data has changed or not.

1. First create an attribute in the component controller or view controller attributes tab.

   


2. Set the data to the attribute on the lead selection or some action befor the data is changed

  wd_comp_controller->gv_record = ls_record.

Note: ls_record gives selected record

3. on enter validate by comparing the data, to check is there any data updated or not

if wd_comp_controller->gv_record = ls_record.

write a message :  no data changed

else.

endif.

Hope this should help you.

Thanks & Regards,

Sankar Gelivi

former_member184578
Active Contributor
0 Kudos

Hi,

Could you  please be more clear? When you want to get the position of cursor? Is it an input field or text view?

You cannot directly get the position of cursor as there are no onfocus( ) events in Web Dynpro ABAP, you must get it via an event say by pressing Enter  etc., If it is an input field, you can get the position of cursor in the onEnter of input field by using r_param->index or the below code;


DATA lr_el_element TYPE REF TO if_wd_context_element.

   DATA lv_index TYPE i.


   lr_el_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

    lv_index = lr_el_element->get_index( ).

Hope this helps u,

Regards,

Kiran

former_member193460
Contributor
0 Kudos

Hi Kiran,

     Thanks for your reply (always helpful ).

Yes, its an input field and  i want to get the position on press of ENTER key.

Can you please elaborate on how to activate this onENTER event for input field inside alv .

Please help

Tashi


former_member184578
Active Contributor
0 Kudos

Hi,

You can use ON_DATA_CHECK event for this purpose and you can set when to trigger ON_DATA_CHECK event; whether when user presses Enter or When press check button .. etc.,

Use the below code:


DATA : lr_table_settings TYPE REF TO if_salv_wd_table_settings,

        lr_model type ref to cl_salv_Wd_Config_Table.

  lr_model = l_ref_INTERFACECONTROLLER->Get_Model( ).

lr_table_settings = lr_model.

*Register DATA_CHECK for Enter

lr_table_settings->if_salv_wd_table_settings~set_data_check( if_salv_wd_c_table_settings=>data_check_on_cell_event_val ).

Now, when you press Enter, your ON_DATA_CHECK Event handler method will get triggered and you can get the index inside the method.

Hope this helps u,

Regards,

Kiran

former_member193460
Contributor
0 Kudos

Hi Kiran,

on_data_check event is triggered only when there is a change of data, i need a method which triggers irrespective of whether data is changed or not.

i am actually doing a mass update functionality, when user presses ENTER, the value in the cell is copied to a node and when the user clicks mass update button, it copies values to all the records for the column.

Please let me know if i can trigger a method without any data change.

Thanks & Regards,

Tashi

former_member184578
Active Contributor
0 Kudos

Hi,

Yes, the ON_DATA_CHECK will get triggered when there is a change in value. If I understood your requirement clearly, you are some value in a column of a row and you want to update that value to all the records of that column. If so, in on action of mass update, read the context node and loop the internal table and set the value to all the records( which is fine if you have a single value) .

If you have a different values and if you want to get the column value on which Enter is pressed, then the option is to enhance the standard component( because the ALV is displaying from Standard component) SALV_WD_TABLE, View  VIEW_TABLE, Method ONACTIONTABLECELL . This method will get called when user presses Enter on any table cell. In ONACTIONTABLECELL from Wdevent you can get the index of the context element. But unfortunately we cannot enhance it as it is a system component.

Regards,

Kiran