Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Edit Field in Oops Alv

Former Member
0 Likes
1,126

Hi Experts,

I am first time working for oops alv can any one please guide me in following requirement.

I have three fields in my output alv say matnr ernam maktx .

1. Only matnr should be in edit mode and remaining two fields should be uneditable .

2. When I change matnr and give ENTER then corresponding Material Description should be dispalyed .

Thanks in advance.

6 REPLIES 6
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
901

check program BCALV_EDIT_03

When I change matnr and give ENTER then corresponding Material Description should be dispalyed

Build you logic in user command

Read only

MarcinPciak
Active Contributor
0 Likes
901

1) In fieldcatalog for AVL sety field edit = 'X' for matnr

2) For this use event data_changed for which you need to implement a handler method in some local class . Once you enter some data in that field, the handler will fire up and here you retrieve corresponding material and show it on screen


CLASS lcl_event_handler DEFINITION .
   PUBLIC SECTION .
      METHODS: handle_data_changed
                        FOR EVENT data_changed OF cl_gui_alv_grid
                        IMPORTING er_data_changed ,
ENDCLASS.

CLASS lcl_event_handler IMPLEMENTATION .
   METHOD handle_data_changed .
      "here selecte text for given material
      "and place it in some other cell of ALV grid
      "er_data_changed contains changed data 
    ENDMETOD.
ENDCLASS.

now set the handler for this event and your alv object


data: gr_handler type ref to lcl_event_handler.

create object gr_handler.

SET HANDLER gr_event_handler->handle_data_changed FOR gr_alvgrid.

Last thing for editability is to call this method


CALL METHOD gr_alvgrid->register_edit_event
    EXPORTING
      i_event_id = cl_gui_alv_grid=>mc_evt_enter "trigger event after ENTER is pressed
    EXCEPTIONS
      error      = 1
      OTHERS     = 2.

That will suffice

Regards

Marcin

Read only

0 Likes
901

Hi Marcin,

I noticed that it was working fine, but the changes are tracking back in the internal table only if we hit the ENTER key. If we change the value in any cell and simply click on the button, changes are not tracking. I checked couple of standard programs also and they are also working in the same way as i mentioned earlier.

is there anyway that we can track the changes without hitting the ENTER key or there is noway at all without hitting ENTER.

Noticed that

SET HANDLER obj_event_rec3->handle_data_changed FOR obj_grid3

is not triggering from PAI, its triggering only on ENTER key, but not triggering from the other pushbuttons.

Thanks

Satya

Read only

0 Likes
901

This is because , you have only registered the ENTER event ..

try registering this event cl_gui_alv_grid=>MC_EVT_MODIFIED like teh enter event is registered. This gets triggered when the cell is modified.

Suzie

Read only

0 Likes
901

Hi Suzie.

Thanks for reponse, i have used that too, its working fine when you move to different cell. If you change content of the cell A & if you dont hit ENTER or move cursor from that cell then changes are not tracking, but when you move cursor from cell A to cell B then changes of cell A is tracking.

Thanks

Satya

Read only

0 Likes
901

Thanks, i got the solutions its because of the button is not from the grid which i am using.