09-03-2010 10:04 AM
Hi All there,
I have a requirement that I have to change the ALV layout at runtime by providing some push button.once the push button pressed I have to refresh the layout.
I got the methods get_frontend_fieldcatlog by which I can read the layout and set_frontend_fieldcatlog bothe belongs to class cl_gui_alv_grid.
Can anybody provide me sample code or anyother option to do this.
Regards
Sagar
09-03-2010 10:12 AM
I think you already have all the logic you need. Where is the problem then?
If this is just a matter of "where to place the code" please just pick any document regarding ALV ( i.e [this|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907] ) and read how to handle event user_command and in the handling method simply use mentioned methods to change the ALV, then refresh it.
Regards
Marcin
09-03-2010 10:18 AM
Hi Mercin,
Thanks for your reply, If I skip the part user-commnad for time being I should be able to read the layout with the method get_frontend_fieldcatalog
but I am getting dump at this method saying.
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
caught and
therefore caused a runtime error.
The reason for the exception is:
You attempted to use a 'NULL' object reference (points to 'nothing')
access a component (variable: "R_GRID").
An object reference must point to an object (an instance of a class)
before it can be used to access components.
Either the reference was never set or it was set to 'NULL' using the
CLEAR statement.
I am not able to understand this.
09-03-2010 10:21 AM
Hi Mercin
just addition to this to my above reply see my sample code.
Data : r_container TYPE REF TO cl_gui_custom_container,
r_grid TYPE REF TO cl_gui_alv_grid.
DATA: t_fcat TYPE lvc_t_fcat,
fs_fcat TYPE lvc_s_fcat.
CALL METHOD r_grid->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = t_fcat.
I think with this I should able to read the the layout but its giving the above dump
Regards
Sagar.
09-03-2010 10:32 AM
Obviously you are trying to change the fieldcatalog for the grid object which was not never instantiated.
You need to:
- create the object itself
create object r_grid
importing parent = ....
- then display it with method set_table_for_first_display passing original fieldcatalog to it
- then you are able to change the fieldcalog with the method you use in some event handling method
I think you are new to ALV grid, ain't you? Please therefore refer some standard programs as you miss basic understanding of the ALV itself. Just go through the document I gave you or have a look at BCALV_GRID_* programs.
Regards
Marcin
09-05-2010 6:53 PM
Hi Sagar,
the sequence should be:
- create grid object
- assign table to be displayed first to field-symbol
- set table for first display (with structure and field-symbol as table
- get frontend field catalog and modify it for new structure
- set frontend field catalog
- assign other table to field-symbol
- call grid refresh method.
Sorry, the coding is not for free
Regards,
Clemens
09-06-2010 8:27 AM
Sorry, the coding is not for free
Clemens, you should suggest the lowest bid
09-15-2010 11:55 AM