If you have a requirement to show some detailed data in an ALV Grid, there are two ways of doing it. You can create your dialog container and assign the grid to the dialog container.
SAP has made the job easier for us by giving a class
, which does exactly the same. Now, all you have to do, is to create the field catalog, create the Grid object and call the method SHOW_DATA. You can even specify the coordinates as to where the grid should appear.
However, the toolbar will NOT appear for this grid but you can have the layout and can chang the way you want it.
Here is the Class
The difference is, here you will have to pass the field catalog / structure which will have the column details, while creating the GRID object as against to doing it while displaying the data in the traditional CL_GUI_ALV_GRID class.
You can also specify the starting coordinates of the grid and width and height of the grid.
And here, while displaying the data, all you have to do is to pass the table, which has the data.
So, now we don’t have to bother about creating a dialog container for showing a ALV grid as popup.
Here is a sample code for the same. I am calling this in the double click event of a MAIN ALV GRID.
CALL FUNCTION ‘LVC_FIELDCATALOG_MERGE’
I_STRUCTURE_NAME = ‘ALV_T_T2’
I_CLIENT_NEVER_DISPLAY = ‘X’
CT_FIELDCAT = T_FIELDCAT1
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CREATE OBJECT W_POPUP_GRID
I_T_FIELDCATALOG = T_FIELDCAT1
I_LEFT = 10
I_TOP = 10
I_HEIGHT = 300
I_WIDTH = 300
CALL METHOD W_POPUP_GRID->SHOW_DATA
I_T_DATA = T_DATA1.
ENDFORM. ” SHOW_DETAILS
Well, nothing exceptional, but definitely a handy one to reduce coding.