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

Alv

Former Member
0 Likes
757

Hi Abapers,

I have created one alv in oops. now when the user enter into change mode and selects one record in displayed alv and clicks on 'deleted row(-)' icon of alv, these record is getting deleted.

my requirement is to capture the deleted record and display deleted records in other alv. how can i achieve this thru 'delete row' icon.

same way i have to capture newly inserted records thru 'append row' option.

kindly help me. very urgent... points are for sure for all helpfull answers.....

Regards,

Radhika.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
714

<a href="http://www.erpgenie.com/sap/abap/controls/alvgrid.htm">refer this</a>

regards,

srinivas

5 REPLIES 5
Read only

Former Member
0 Likes
714

Hi Premraj,

If your using the ALV standard User Interface, then try with this method to get the modified data from the output screen "check_changed_data"

Read only

Former Member
0 Likes
714

Hi Radhika,

You can go through the document given below. See if it is useful.

<i>Controlling Data Changes:</i>

As we can now make our ALV Grid editable we may require controlling input data. The ALV Grid has events <i>“data_changed”</i> and <i>“data_changed_finished”</i>. The former method is triggered just after the change at an editable field is perceived. Here you can make checks for the input. And the second event is triggered after the change is committed.

You can select the way how the control perceives data changes by using the method <i>“register_edit_event”</i>. You have two choices:

i. After return key is pressed: To select this way, to the parameter <i>“i_event_id”</i> pass <i>“cl_gui_alv_grid=>mc_evt_enter”.</i>

ii. After the field is modified and the cursor is moved to another field: For this, pass<i> “cl_gui_alv_grid=>mc_evt_modifies”</i> to the same parameter.

To make events controlling data changes be triggered, you must select either way by calling this method. Otherwise, these events will not be triggered.

To control field data changes, ALV Grid uses an instance of the class <i>“CL_ALV_CHANGED_DATA_PROTOCOL”</i> and passes this via the event <i>“data_changed”.</i> Using methods of this class, you can get and modify cell values and produce error messages. Here are some of those methods:

<i>get_cell_value</i> -> Gets the cell value. You pass the address of the cell to the interface.

<i>modify_cell</i> -> Modifies the cell value addressed via parameters.

<i>add_protocol_entry</i> -> Add a log entry. You make use of standard message interface with message type, message id, etc…

<i>protocol_is_visible</i> -> Make the error table visible or not.

<i>refresh_protocol</i> -> Refreshing log entries.

With the reference of the instance, you can reach information about modifications. These useful attribute tables are:

<i>MT_MOD_CELLS</i> -> Contains addresses of modified cells with “<i>row_id</i>”s and “<i>fieldname</i>”s.

<i>MP_MOD_ROWS</i> -> Contains modified rows. Its type is generic.

<i>MT_GOOD_CELLS</i> -> Contains cells having proper values

<i>MT_DELETED_ROWS</i> -> Contains rows deleted from the list

<i>MT_INSERTED_ROWS</i> -> Contains rows inserted to the list

Utilizing these methods and attributes you can check and give proper message and also modify the cell content.

<i>Example :

Code – Checking the input together with a non-input value, adding a log and modifying the cell content</i>

FORM handle_data_changed USING ir_data_changed

TYPE REF TO cl_alv_changed_data_protocol.

DATA : ls_mod_cell TYPE lvc_s_modi ,

lv_value TYPE lvc_value .

SORT ir_data_changed->mt_mod_cells BY row_id .

LOOP AT ir_data_changed->mt_mod_cells

INTO ls_mod_cell

WHERE fieldname = 'SEATSMAX' .

CALL METHOD ir_data_changed->get_cell_value

EXPORTING i_row_id = ls_mod_cell-row_id

i_fieldname = 'CARRID'

IMPORTING e_value = lv_value .

IF lv_value = 'THY' AND ls_mod_cell-value > '500' .

CALL METHOD ir_data_changed->add_protocol_entry

EXPORTING

i_msgid = 'SU'

i_msgno = '000'

i_msgty = 'E'

i_msgv1 = 'This number can not exceed 500 for '

i_msgv2 = lv_value

i_msgv3 = 'The value is et to ''500'''

i_fieldname = ls_mod_cell-fieldname

i_row_id = ls_mod_cell-row_id .

CALL METHOD ir_data_changed->modify_cell

EXPORTING i_row_id = ls_mod_cell-row_id

i_fieldname = ls_mod_cell-fieldname

i_value = '500' .

ENDIF .

ENDLOOP .

ENDFORM "<i>handledatachanged</i>

Reward Points if this is helpful to u.

Read only

0 Likes
714

Hi Bhanu,

Can u plz give me some sample program where data changes are captured.

Regards,

Radhika.

Read only

Former Member
0 Likes
715

<a href="http://www.erpgenie.com/sap/abap/controls/alvgrid.htm">refer this</a>

regards,

srinivas

Read only

Former Member
0 Likes
714

Radhika,

Did u get it?