04-01-2011 12:14 PM
Hi everybody,
I'm really going crazy over this one: I'm developing an editable ALV using CL_GUI_ALV_GRID and I'm trying to check the entered data both on pressing enter and on pressing SAVE.
Since I want to use the error log protocol I'm doing all of these check in the data_changed event handling. Now this is where it gets tricky: When a user enters a value and presses the SAVE button without pressing enter first, the following code is executed:
CALL METHOD GOB_D1100_ALV02_GRID->CHECK_CHANGED_DATA
So since I registered the data_changed event, will trigger the event handling BEFORE transporting the value from the GUI to the internal table. The value is only transfered after the data_changed event (where I want to make my checks because of the error protocol) is executed.
How do I get my internal table updated before event handling?
Best wishes,
Ben
04-01-2011 12:29 PM
Hello Ben,
If i see the method CHECK_CHANGED_DATA, there is the call to the pvt. method SAVE_DATA which raises the event DATA_CHANGED.
Btw why do you want the data to be transferred to the internal table before the event DATA_CHANGED is triggered?
Cheers,
Suhas
04-01-2011 1:33 PM
Hi Suhas,
I need to have the current data in my internal table, because in event handling of DATA_CHANGED, I want to check if the data is correct and if it's not I add protocol entries. I can only add protocol entries in my event handling because only there I can access
CALL METHOD P_ER_DATA_CHANGED->ADD_PROTOCOL_ENTRY
So what do you suggest, how can I transport the data of my alv to my internal table so that I have the current state when DATA_CHANGED is called?
Regards,
Ben
04-01-2011 2:02 PM
Hello Ben,
I need to have the current data in my internal table, because in event handling of DATA_CHANGED, I want to check if the data is correct and if it's not I add protocol entries.
You don't have to do this checking explicitly!
The method SPLIT_GOOD_AND_BAD splits the records into good_cells & bad_cells. And based on these, the "good" values are added to the internal table.
I suggest you debug the method CHECK_CHANGED_DATA to get a clear picture. Also did you check the demo program BCALV_EDIT_03?
BR,
Suhas
04-01-2011 2:12 PM
Hi Suhas,
the thing is, I need to do my own checks in DATA_CHANGED and can not rely on the checks made by SAP!
Yes I had a look at BCALV_EDIT_03 and all the other demo reports, but the big difference is, that all of them only do ONE check, meaning either check when saving, or check when entering new data. I need to check both though!
I really don't know how to accomplish this. It would be sufficient for me if there was a way to transport the data to the internal table, without triggering anything else.
Ben
04-01-2011 3:30 PM
YEHAW! I found a solution to my problem in this thread:
What you need to do is change your internal table yourself accordingly to the changes that you did on the ALV GRID.
You can find the modified rows in table MP_MOD_ROWS of object P_ER_DATA_CHANGED.
Then all you need to do is modify your internal table accordingly. Works like a charm (:
FORM ALV_EVENT_DATA_CHANGED USING P_ER_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL
P_SENDER.
DATA: LTA_MOD_CELLS TYPE LVC_T_MODI.
DATA: LST_MOD_CELLS TYPE LVC_S_MODI.
FIELD-SYMBOLS: <LFS_MOD_ROWS> TYPE TABLE.
LOOP AT P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LST_MOD_CELLS.
ASSIGN P_ER_DATA_CHANGED->MP_MOD_ROWS->* TO <LFS_MOD_ROWS>.
READ TABLE <LFS_MOD_ROWS> ASSIGNING <FS_D1100_ALV02_DATA> INDEX LST_MOD_CELLS-TABIX.
MODIFY GTA_D1100_ALV02_DATA FROM <FS_D1100_ALV02_DATA> INDEX LST_MOD_CELLS-ROW_ID.
ENDLOOP.
Thank you very much for your assitance
Ben