Skip to Content

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

CL_RS_ALV_GRID_POPUP

, 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

image

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.

image

And here, while displaying the data, all you have to do is to pass the table, which has the data.

image

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.

-CARRID.

  ELSE.

    EXIT.

  ENDIF.

  CALL FUNCTION ‘LVC_FIELDCATALOG_MERGE’

   EXPORTING

  •    I_BUFFER_ACTIVE              =

      I_STRUCTURE_NAME             = ‘ALV_T_T2’

  •    I_CLIENT_NEVER_DISPLAY       = ‘X’

  •    I_BYPASSING_BUFFER           =

  •    I_INTERNAL_TABNAME           =

    CHANGING

      CT_FIELDCAT                  = T_FIELDCAT1

  • EXCEPTIONS

  •    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.

  ENDIF.

  CREATE OBJECT W_POPUP_GRID

     EXPORTING

  •    I_STRUCTURE_NAME =

       I_T_FIELDCATALOG = T_FIELDCAT1

  •    I_S_LAYOUT =

  •    I_CAPTION =

  •    I_REPID =

  •    I_DYNNR =

       I_LEFT = 10

       I_TOP  = 10

       I_HEIGHT = 300

       I_WIDTH = 300

      .

  CALL METHOD W_POPUP_GRID->SHOW_DATA

    EXPORTING

      I_T_DATA = T_DATA1.

  .

ENDFORM.                    ” SHOW_DETAILS

</textarea>

Well, nothing exceptional, but definitely a handy one to reduce coding.

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Anonymous
    Hi,

    Does anyone have a small sample program for this class that they are willing to post here?

    Thanks,
    James Gaddis

    (0) 
    1. Anonymous
      Hi Ravi,

      Appreciate the sample code.  I made a copy of the standard SAP sample program BCALV_GRID_03 and implemented your popup subroutine for the double-click method.  Instead using “call screen 101” in method handle_double_click, I used the following  slightly modified version of your subroutine with good results:

      FORM SHOW_DETAILS.

        DATA : T_FIELDCAT1 TYPE LVC_T_FCAT,
               W_POPUP_GRID TYPE REF TO CL_RS_ALV_GRID_POPUP.

        CALL FUNCTION ‘LVC_FIELDCATALOG_MERGE’
         EXPORTING
            I_STRUCTURE_NAME             = ‘SBOOK’
          CHANGING
            CT_FIELDCAT                  = T_FIELDCAT1.

        CREATE OBJECT W_POPUP_GRID
           EXPORTING
             I_T_FIELDCATALOG = T_FIELDCAT1
             I_LEFT = 20
             I_TOP  = 300
             I_HEIGHT = 300
             I_WIDTH = 500.

        CALL METHOD W_POPUP_GRID->SHOW_DATA
          EXPORTING
            I_T_DATA = gt_sbook.
           
      ENDFORM.                    ” SHOW_DETAILS

      Thanks again,
      James

      (0) 
  2. K.Anil Kumar
    Hi Ravi,

       This blog is really good. it is handy also. But This class is not there in
    SAP R/3 Enterprise version. I think it is only in higher versions than this.

    Regards
    Anil Kumar K

    (0) 
    1. Ravikumar Allampallam Post author
      Hi Anil,

      I think you haven’t looked at the description of the blog, where I clearly mentioned that this is a part of WAS 6.40 and SAP Enterprise versions runs on WAS 6.20.

      Regards,
      Ravi

      (0) 
  3. Clemens Li
    Sure, this is a nice idea I already intergrated into a couple of programs. Looking at the code, it is not too much more.

    Unfortunately, this object has not been inherited from anywhere. Thus we can’t work with any events, have no access to any control data (selection, focus,…).

    Furthermore the class is declared FINAL not allowing us to add anything.

    Conclusion: Nice tool but not really OO compliant.

    Regards

    Clemens Li

    (0) 

Leave a Reply