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-Grid (OO): trigger event CHANGED_DATA when creating/filling grid table

Former Member
0 Likes
2,068

Hi there,

I have a grid table being filled of which I know, that it doesn't contain all necessary data to allow the user to continue.

As there are no mandatory flags to the fields I want to call a method (e.g. SET_DELTA_CELLS: it's marked INTERNAL only and doesn't seam to work anyway) to emulate user input or just trigger the event DATA_CHANGED.

I also thought about using method ADD_ROWS, but I don't need excess rows that I need to remove again.

What other possibilities are there?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,729

The internal method 'set_delta_cells' is working for me. I've figured out, the best way should be to do call the method 'check_changed_data' before and after you call it.

This is what I'm doing:

1. Call 'check_changed_data' to get all fields changed by the user to the internal table.

2. Search internal table for wrong (initial in my case) fields which are not changed by the user and call 'set_delta_cells' for them.

3. Call 'check_changed_data' again, and now the fields are processed in the data changed event.

Use the method CHECK_CHANGED_DATA of the CL_GUI_ALV_GRID.

Like:


    o_alv->check_changed_data(
      IMPORTING
        e_valid = lf_valid ).

This method calls the SAVE_DATA and in turn SAVE_DATA will trigger the DATA_CHANGED event.

Regards,

Naimesh Patel

6 REPLIES 6
Read only

Former Member
0 Likes
1,729

hello alan ,

what u can do is when user press ENTER on the screen then u can call methid check_data_changed.

u can trigger that event only when user enters do some actions like ENTER or any other Function Codes.

user_command.

case 'ENTER'.

*---LOCALS.

data: l_stable type lvc_s_stbl.

*---refresh locals.

clear: l_stable.

call method g_grid%->check_changed_data.00-->in this method u can do validations based on the user inputs.

*---softrefresh.

l_stable-row = 1.

l_stable-col = 1.

call method g_grid%->refresh_table_display

exporting

is_stable = l_stable

i_soft_refresh = 'X'.

regards

Prabhu

Read only

0 Likes
1,729

Hi Prabhu,

thanks for your answer.

Alas, it would require the user to actively change a field and press ENTER or change a cell in order for DATA_CHANGED to being fired.

The point is, that I need to check certain data independent of user action (change of cell data). If the user presses the save/ok/continue button he must not be allowed to continue unless all data of the grid is filled where required.

regards

Alan

Read only

0 Likes
1,729

>

> Hi Prabhu,

>

> thanks for your answer.

> Alas, it would require the user to actively change a field and press ENTER or change a cell in order for DATA_CHANGED to being fired.

>

> The point is, that I need to check certain data independent of user action (change of cell data). If the user presses the save/ok/continue button he must not be allowed to continue unless all data of the grid is filled where required.

>

> regards

> Alan

Hi Alan,

You could write a subroutine which will do all the validations and call this subroutine for every user action for which you think the data should be validated. You could pass the old and new table to this subroutine and compare the values to see if the requirement is fulfilled and the data is valid.

Hope this helps.

Best regards,

Advait

Read only

Former Member
0 Likes
1,730

The internal method 'set_delta_cells' is working for me. I've figured out, the best way should be to do call the method 'check_changed_data' before and after you call it.

This is what I'm doing:

1. Call 'check_changed_data' to get all fields changed by the user to the internal table.

2. Search internal table for wrong (initial in my case) fields which are not changed by the user and call 'set_delta_cells' for them.

3. Call 'check_changed_data' again, and now the fields are processed in the data changed event.

Read only

naimesh_patel
Active Contributor
0 Likes
1,729

Use the method CHECK_CHANGED_DATA of the CL_GUI_ALV_GRID.

Like:


    o_alv->check_changed_data(
      IMPORTING
        e_valid = lf_valid ).

This method calls the SAVE_DATA and in turn SAVE_DATA will trigger the DATA_CHANGED event.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
1,729

The problem is, the changed_data event will contain only fields which are actually changed by the user - this can be emulated with the set_delta_cells method, as stated before.