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

handle_data_changed - triggered

Former Member
0 Likes
2,783

hello

I am using ALV display - classes (cont , grid etc...)

I am displaying an editable internal table

whenever i push the little button on the MATNR field - the one that display the sample options of MATNR...

its triggers the handle_data_changed event.

and for so the table "mt_inserted_rows" is deleted after this first touch of the screen.

how can i avoid this without using the sy-ucomm...

btw : to trigger the event manually i used the sy-ucomm.

thanks ahead

specially to those who understood the problem.

Eyal.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,320

Hello Eyal

To be honest I do no really understand your problem, particularly what you mean by <i>"...the little button on the MATNR field - the one that display the sample options of MATNR</i>...".

However, I do understand how event handling of the grid control works:

- You have an editable grid control. The user has changed some data.

- When the user executes a function that will lead to PAI (e.g. ENTER, SAVE) then you must call the instance method CHECK_DATA_CHANGED otherwise the changes on the ALV list will not be transported to your itab in the ABAP program (nor will event DATA_CHANGED be raised)

- Since the user changed some data CHECK_DATA_CHANGED will raise event DATA_CHANGED. Now the changes are transported to the itab in ABAP.

- If, for example, you want to validate the changed data then you have to define an event handler (e.g. HANDLE_DATA_CHANGED).

That is the logic of event handling for editable grid controls.

Regards

Uwe

6 REPLIES 6
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,321

Hello Eyal

To be honest I do no really understand your problem, particularly what you mean by <i>"...the little button on the MATNR field - the one that display the sample options of MATNR</i>...".

However, I do understand how event handling of the grid control works:

- You have an editable grid control. The user has changed some data.

- When the user executes a function that will lead to PAI (e.g. ENTER, SAVE) then you must call the instance method CHECK_DATA_CHANGED otherwise the changes on the ALV list will not be transported to your itab in the ABAP program (nor will event DATA_CHANGED be raised)

- Since the user changed some data CHECK_DATA_CHANGED will raise event DATA_CHANGED. Now the changes are transported to the itab in ABAP.

- If, for example, you want to validate the changed data then you have to define an event handler (e.g. HANDLE_DATA_CHANGED).

That is the logic of event handling for editable grid controls.

Regards

Uwe

Read only

0 Likes
2,320

Hello Uwa.

Thanks for replying.

The little button on the MATNR field - its F4 func - when I push this button a window opens and I can choose which MATNR I want to use.

I'll try to describe the scenario:

- I want to enter a new record in my DB-table - insert line (which have the MATNR field).

- I want to choose which MATNR will be in this new line

- I push the little button (F4)

- When I do so it triggered the "Data_Changed"

- For now, the it_table does not change

- But, the system table which handled by the Data_Changed trigger - "mt_inserted_rows" - does change and now holds the new line's number and its value - NULL or ' '.

- After I insert all the other values I push the 'Save' button and its triggers the PAI which triggers the "Handle_Data_Change".

- But now, the "mt_inserted_rows" is now 'initial' and I all of its data is lost.

I need this table in order not to search the new it_table for its new record. (and insert it to my DB_table)

Hope it is more clear now.

thanks ahead

with regards.

Eyal Cohen.

Read only

0 Likes
2,320

Populate the it_table in F4 event

Read only

Former Member
0 Likes
2,320

Howdy Eyal,

Why dont you use the parameters that come through with the 'data_changed' event? It will set the flags (E_ONF4, E_ONF4_BEFORE, E_ONF4_AFTER). Is this what you mean, ie how to tell when this event was called by F4?

Also, I think 'so what?' if it disappears from mt_inserted_rows because afterwards it will be in mt_modified_rows instead. If you need to validate the whole row at once, then add a validation field/flag to your display table and flag it as technical in the fieldcat (fcat-tech = 'X'). You can manually set this flag when a row is ok.

Hope this helps,

Phil.

Read only

0 Likes
2,320

Hello phillip

Let me try to clear up my question.

I just don't want that the event - "data change" will be activate when i push the F4 button on some fields.

I didn't understand the first part of your answer - " It will set the flags (E_ONF4, E_ONF4_BEFORE, E_ONF4_AFTER). "

Although the second part of your answer is good and probably work - it is not an elegant solution

Thanks neway and with best regards.

Eyal.

Read only

0 Likes
2,320

Hi Eyal,

Let me clear up the first part of my answer.

If you look at cl_gui_alv_grid >> events tabs, you will see a data_changed event with 4 parameters - those 3 flags and a instance of cl_alv_changed_data_protocol.

Now in your event handler class you would be responding to these events with a method. Now the method probably just calls a form somewhere in your program - and it probably only passes the cl_alv_changed_data_protocol, and not the flags.

So the flags are definitely there in the event you just may not be using them in your form.

Also have a look at the public atrribute MT_DELTA_CELLS_INSERTED

of cl_gui_alv_grid

I'm not sure but this may keep a global record of changed data.

But if you want the data_changed event to be triggered when they manually enter data, but <b>not</b> when they use F4 - this will be very hard. You probably have to extend class cl_gui_alv_grid.

Or try using set_registered_events( ). You'll have to hunt the the attributes of cl_gui_alv_grid to find a likely event to turn off tho.

Cheers,

Phil.

Message was edited by: Phillip Manning