12-31-2015 12:23 PM
Hi All,
I went through multiple threads on SCN to get solution for this issue but couldn't succeed.
1. Solution Didn't work
2 .Solution Didn't work
ALV functionality using OOPS - Code Gallery - SCN Wiki
3. Solution Didn't work
Editable ALV -- OO -- Changed data capture | SCN
ER_DATA_CHANGED->MODIFY_CELL for event DATA_CHANGED is working fine and showing recent values on screen.
But when I press save, internal table which I used in SET_TABLE_FOR_FIRST_DISPLAY is not showing recent/ updated values on screen in PAI.
I checked content of IT_OUT after exciting this method GO_CL_GUI_ALV_GRID->CHECK_CHANGED_DATA. But it has old values.
Any idea why this is happening. Please suggest in case I am missing anything.
Thanks.
12-31-2015 12:34 PM
Hi,
Have a look at programs BCALV_EDIT_03 and BCALV_TEST_GRID_EDITABLE .
Learn how those programs works and then review your own code.
Regards.
12-31-2015 12:58 PM
The 'Save' button, I am assuming is on the standard report screen? If so then the event is occuring outside of the ALV grid and does not trigger any grid events.
In my User command routines (called during PAI), I do the following:
Data: l_Leave Type Boolean,
l_Valid Type Boolean,
lt_Original_Display Type Display_Table.
*
* Save a copy of the display table so we can check to see if a refresh is
* needed.
*
lt_Original_Display = es_Screen_0100-Display_Table.
Call Method es_Screen_0100-Alv_Grid->Check_Changed_Data
Importing
e_Valid = l_Valid.
*
* Only do this if there is no error screen.
*
If l_Valid = Abap_True.
Case es_Screen_0100-Ok_Code.
So, I am basically doing the same as yourself.
You have defined event handlers for Data_Changed and Data_Changed_Finished ?
Regards
Rich
12-31-2015 1:18 PM
Hi Rich,
Thanks for the reply.
I have done event handling for Data_Changed and it is triggering properly with recent data shown on screen.
However, in PAI, GT_OUT internal table does not have recent data in some of the cases -- when I DO MULTIPLE UPDATE CREATE AND DELETE SIMULTANEOUSLY in the same grid and then press SAVE..
12-31-2015 1:22 PM
And Data_Changed_Finished ?
The data will not appear in the table in PAI until you have called the Check_Changed_Data method. Until then the table is not updated.
Rich
12-31-2015 1:26 PM
Yes.. I am calling Check_Changed_Data using GRID object as mentioned in my origibal post.
but sometimes it fails to give recent data when I DO MULTIPLE UPDATE CREATE AND DELETE SIMULTANEOUSLY ..
12-31-2015 1:38 PM
No need to shout...
You still have not said whether you have handled Data_Changed_Finished ?
I've just checked it the same type of scenario here and the data table is changed. The only thing I can see different at the moment is that you do not seem to have implemented Data_Changed_Finished.
12-31-2015 1:44 PM
Rich... I am not shouting.. I am just highlighting by writing it in Capitals similar to method names which I wrote earlier in caps.
Data_Changed_Finished method is of no use as it never return anything in internal tables.
12-31-2015 1:52 PM
That may be true, but DATA_CHANGED_FINISHED is where the data is transferred to the gt_table if there are no errors. I have implemented the event becuase I am setting a data changed flag. As I said above the only thing at the moment I can see different is that I have implemented the DATA_CHANGED_FINISHED event and you haven't, so to eliminate the possibility, just implement and empty method and try that.
Rich
12-31-2015 1:59 PM
okay..
But since DATA_CHANGED_FINISHED is not returning anything, what code you wrote into it...
please confirm.
Also I am showing error message on screen . This issue is there when I put invalid values in cell ..
Do I need to to take any precautions for clearing glabal references before i display error.
12-31-2015 2:13 PM
Sachin Adak wrote:
Also I am showing error message on screen . Do I need to to take any precautions for clearing glabal references before i display error.
Hmmm....
Ok, I'm not sure I understand your meaning here.
You - the programmer, when using the event DATA_CHANGED are not responsible for showing error messages on the screen. You add a message to the error object protocol:
Call Method io_Protocol->Add_Protocol_Entry
Exporting
i_MsgId = c_mc_MLOR_Control
i_MsgTy = Me->Get_Message_Type_Error( )
i_MsgNo = '022'
i_MsgV1 = i_SPart
i_MsgV2 = i_VkOrg
i_FieldName = 'SPART'
i_Row_Id = i_TabIx.
But... If your program is already showing an error message then thta explains why your changes are not appearing in gt_table. They will only appear when the alv_grid is error free.
As for Global references, no - not really although it depends on how you program is constructed.
As to what is in my Data_Changed_Finished method it is:
Method Handle_DATA_CHANGED_FINISHED.
*
If e_Modified = Abap_True.
*
* Set the global changed flag.
*
Me->Set_Data_Changed( Abap_True ).
EndIf.
EndMethod.
Regards
Rich
12-31-2015 2:45 PM
Moderator message. Using all capitals for emphasis is widely regarded as the typing equivalent of shouting, and certainly comes across as quite rude. You could use the bold font, but even then it gives the impression of "oy, stupid, didn't you read this bit?"
12-31-2015 2:56 PM
Ok, Give up time.....
Please don't change a post that I have already replied to, especially using bold and underline as though it was there to start off with. You will see that I have already quoted that part of the message in my reply.
How many posts did it take for you to mention the errors ? That is why your data is not being updated and would have been quite an easy answer.
There is nothing wrong in being full and frank with your information to start with - very often that will achieve a quicker resoloution than pulling teeth and then having to guess what they are.
Regards
Rich
12-31-2015 4:10 PM
Call Method io_Protocol->Add_Protocol_Entry Exporting i_MsgId = c_mc_MLOR_Control i_MsgTy = Me->Get_Message_Type_Error( ) i_MsgNo = '022' i_MsgV1 = i_SPart i_MsgV2 = i_VkOrg i_FieldName = 'SPART' i_Row_Id = i_TabIx.
But... If your program is already showing an error message then thta explains why your changes are not appearing in gt_table. They will only appear when the alv_grid is error free.
ALV grid can show error messages using 'ADD_PROTOCOL_ENTRY' but it is not necessary that user corrects the error and then only control moves forward. IF user simply closes the error log and press save then incorrect data records comes to output table.
Please check reply from Ryan for this standard behavior.
So I guess there is no restriction that output table should be error free as we can not make sure that user always corrects the error.
That's the reason I am showing error messages in PAI after save button is clicked.
01-04-2016 8:25 AM
I've been using the object ALV Grid now for many, many years, in many projects. If a method or attribute is protected or private then it's protected or private for a reason. However, I have never ever noticed that you can bypass the error checking or display just by closing the error window. The only time you do not get a 'False' value in the valid parameter of Check_Data_Changed is if method Data_Changed_Finished is called and no other changes have been made. Allowing erroneous data into the grid does not make sense.
I have just checked this on an ALV grid that I have here and Ryan's observations do not hold.
Regards
Rich