Dear fellow ABAP developers,
I am using CL_GUI_ALV_GRID to create an editable ALV grid.
Now, I have been asked to set a specific ALV variant (created by us before delivering this report) once the user clicks a button that I added to the toolbar.
I know there is standard functionality to do so (through the usual button for Chosing/Chaging/Saving/Managing Layouts), but the fact is that the button will not only set the different layout, but also set some filters (which I successfully achieved already).
I have seen that method CL_GUI_ALV_GRID->SET_VARIANT exists. I tried to use it, to achieve my result, but calling the method did not work: the layout of the ALV grid stayed the same as before.
In order to be sure 100% to use a correct disvariant structure, I selected (using "INTO CORRESPONDING FIELDS) from table LTDX. Still, no result. I checked the code and actually the method is only changing value of m_cl_variant->ms_variant.
This is a public attribute of class CL_ALV_VARIANT, which is the type of object m_cl_variant. Unluckily, this object is private, so I cannot try to do to much with that. :-(
Since nothing else was performed by that method, I tried also to call method CL_GUI_ALV_GRID->REFRESH_TABLE_DISPLAY afterwards, but still no results. I tried both a soft and a hard refresh.
In the end, I managed to do what I wanted by deleting and recreating the entire grid. But I feel this is not correct and it might raise other kind of issues.
So, does anybody know how to use method CL_GUI_ALV_GRID->SET_VARIANT?