Skip to Content
Author's profile photo Georgiy Shlyakhov

Very simple ALV in pop-up window

Hello, colleagues!

It may be useful in everyday programming to use quick and simple solutions.

So, I wrote a function module ‘Z_VERY_SIMPLE_ALV’ which allows you to display an ALV grid in a pop-up window at railway speed.

Here you can see the FM:

FUNCTION z_very_simple_alv.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"    REFERENCE(I_START_COLUMN) TYPE  I DEFAULT 25
*"    REFERENCE(I_START_LINE) TYPE  I DEFAULT 6
*"    REFERENCE(I_END_COLUMN) TYPE  I DEFAULT 100
*"    REFERENCE(I_END_LINE) TYPE  I DEFAULT 10
*"    REFERENCE(I_TITLE) TYPE  STRING DEFAULT 'ALV'
*"    REFERENCE(I_POPUP) TYPE  FLAG DEFAULT ' '
*"  TABLES
*"      IT_ALV TYPE  STANDARD TABLE
*"----------------------------------------------------------------------

  DATA go_alv TYPE REF TO cl_salv_table.

  TRY.
      cl_salv_table=>factory(
        IMPORTING
          r_salv_table = go_alv
        CHANGING
          t_table      = it_alv[] ).

    CATCH cx_salv_msg.
  ENDTRY.

  DATA: lr_functions TYPE REF TO cl_salv_functions_list.

  lr_functions = go_alv->get_functions( ).
  lr_functions->set_all( 'X' ).

  IF go_alv IS BOUND.
    IF i_popup = 'X'.
      go_alv->set_screen_popup(
        start_column = i_start_column
        end_column  = i_end_column
        start_line  = i_start_line
        end_line    = i_end_line ).
    ENDIF.

    go_alv->display( ).

  ENDIF.

ENDFUNCTION.

You can use it like this:

REPORT z_very_simple_alv.

DATA gt_tab TYPE STANDARD TABLE OF sflights.

SELECT * FROM sflights INTO TABLE gt_tab.

CALL FUNCTION 'Z_VERY_SIMPLE_ALV'
  TABLES
    it_alv = gt_tab.

As a result, you will see the ALV in a full screen window:

/wp-content/uploads/2014/05/1_452501.png

The ALV grid displays in a full screen window by default, but if you set optional I_POPUP importing parameter as ‘X’ then the ALV will be displayed in a pop-up window:

REPORT z_very_simple_alv_popup.

DATA gt_tab TYPE STANDARD TABLE OF sflights.

SELECT *
  FROM sflights
  INTO TABLE gt_tab.

CALL FUNCTION 'Z_VERY_SIMPLE_ALV'
  EXPORTING
    i_popup = 'X'
  TABLES
    it_alv  = gt_tab.

The ALV grid in a pop-up window:

/wp-content/uploads/2014/05/2_452706.png

Best regards,
Georgiy Shlyahov

Assigned Tags

      24 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo vamsilakshman pendurti
      vamsilakshman pendurti

      Good Job.........!

      But in se24 that class( cl_reca_gui_f4_popup ) was not found.....

      how could we call that class with out there in sap..

      it will ask like as follow screen shot..

      just see this ..

      Regards ,

      vamsii......

      Author's profile photo Georgiy Shlyakhov
      Georgiy Shlyakhov
      Blog Post Author

      Hi Vamsilakshman,

      I updated the code as it was advised by Suhas Saha, so, now you may be able to use it in your SAP system.

      Best regards,

      George Shlyahov

      Author's profile photo vamsilakshman pendurti
      vamsilakshman pendurti

      Hi George ...

      thanks for reply..

      now its working....

      Regards

      vamc

      Author's profile photo Tomas Buryanek
      Tomas Buryanek

      Hi George,

      any special reason why have you decided to use cl_reca_gui_f4_popup over common cl_salv_table? Also you are not returning any value (that is what is "F4" used for)...

      Author's profile photo vamsilakshman pendurti
      vamsilakshman pendurti

      Hi George....

      I checked my system Component version : SAP ECC 6.0....

      And

      Using system variable SY-SAPRL in  my program .....

      it will show me like 700.....

      So u mean to say its not working becoz of 700....? RT..?




      Thanks

      Vamc...

      Author's profile photo Former Member
      Former Member

      The class CL_RECA_GUI_F4_POPUP is part of software component EA-APPL. So it's availability is not dependent on your ABAP/Basis release.

      I would not suggest anyone using this class. You can check the demo program SALV_DEMO_TABLE_POPUP, it uses CL_SALV_TABLE to show the ALV as popup.

      BR,

      Suhas

      Author's profile photo Georgiy Shlyakhov
      Georgiy Shlyakhov
      Blog Post Author

      Hi Suhas!

      To follow your advice I updated the code in this document in such a way as to use CL_SALV_TABLE class.

      However, if you have to display a modest pop-up window with custom title and user ability to select one or several rows, which you will work with, i assume it is much better to use CL_RECA_GUI_F4_POPUP class. It has handy methods for this as compared with CL_SALV_TABLE class.

      You can see below the FM which displays simple ALV grid in a pop-up window:

      FUNCTION z_very_simple_alv_f4_popup.
      *”———————————————————————-
      *”*”Local interface:
      *”  IMPORTING
      *”    REFERENCE(I_START_COLUMN) TYPE  I DEFAULT 25
      *”    REFERENCE(I_START_LINE) TYPE  I DEFAULT 6
      *”    REFERENCE(I_END_COLUMN) TYPE  I DEFAULT 100
      *”    REFERENCE(I_END_LINE) TYPE  I DEFAULT 10
      *”    REFERENCE(I_TITLE) TYPE  STRING DEFAULT ‘ALV’
      *”  TABLES
      *”      IT_ALV TYPE  STANDARD TABLE
      *”———————————————————————-
      
         DATA:
          go_popup  TYPE REF TO cl_reca_gui_f4_popup,
          gf_choice TYPE flag.
      
         CALL METHOD cl_reca_gui_f4_popup=>factory_grid
          EXPORTING
            it_f4value    = it_alv[]
            if_multi      = abap_false
            id_title      = i_title
          RECEIVING
            ro_f4_instance = go_popup.
      
         CALL METHOD go_popup->display
          EXPORTING
            id_start_column = i_start_column
            id_start_line  = i_start_line
            id_end_column  = i_end_column
            id_end_line    = i_end_line
          IMPORTING
            et_result      = it_alv[]
            ef_cancelled    = gf_choice.
       
      ENDFUNCTION.

       

      You can use it like this:

      REPORT z_test.
      
      DATA gt_tab TYPE STANDARD TABLE OF sflights.
      
      SELECT *
        FROM sflights
        INTO TABLE gt_tab.
      
      CALL FUNCTION 'Z_VERY_SIMPLE_ALV_F4_POPUP'
        TABLES
          it_alv  = gt_tab.

      It is clear that CL_RECA_GUI_F4_POPUP class does’t replace CL_GUI_ALV_GRID class. But it is quite useful to display simple grids with small range of functionality.

       

      Best regards,

      George Shlyahov

      Author's profile photo Former Member
      Former Member

      It is clear that CL_RECA_GUI_F4_POPUP class does't replace CL_GUI_ALV_GRID class. But it is quite useful to display simple grids with small range of functionality.

      The RECA class uses the SALV-OM to display the popup, not the GUI classes directly.

      which you will work with, i assume it is much better to use CL_RECA_GUI_F4_POPUP class. It has handy methods for this as compared with CL_SALV_TABLE class.

      The RECA class just encapsulates the SALV-OM methods in the DISPLAY( ) method.

      May be you did not get my point. I am not saying not to use it, if it's available in your system use it. The RECA class is in the EA-APPL s/ware component and IMO there is not guarantee that it is available in every SAP installation. The correct approach should be the one followed by Eitan Rosenberg.

      In my current project, i have created a Menu-exit where i have used the SALV-OM to display the popup & handle several user interactions.

      BR,

      Suhas

      Author's profile photo Gaurab Banerji
      Gaurab Banerji

      works for me on EHP7 for SAP ERP 6.0. thanks for the code its very useful.. bookmarking it

      Author's profile photo Former Member
      Former Member

      Hi George ;

      It is very useful.Thanks.

      Regards.

      Özgün

      Author's profile photo Eitan Rosenberg
      Eitan Rosenberg

      Hi,

      This is a thought inspiring post so I did the same thing but with a class.

      Also I add the option to get a double_click info .

      This is a local class but it can be transformd to global ABAP classes (SE24) .

      Regards.

      REPORT  y_r_eitan_test_08_18 .
      
      *----------------------------------------------------------------------*
      *----------------------------------------------------------------------*
      CLASS my_cl_salv_pop_up DEFINITION .
      
        PUBLIC SECTION .
      
          CLASS-DATA: BEGIN OF st_double_click .
          CLASS-DATA: row     TYPE salv_de_row ,
                      column  TYPE salv_de_column .
          CLASS-DATA: END OF st_double_click .
      
          CLASS-METHODS: popup
                   IMPORTING
                      start_line   TYPE i DEFAULT 2
                      end_line     TYPE i DEFAULT 15
                      start_column TYPE i DEFAULT 25
                      end_column   TYPE i DEFAULT 150
                      popup        TYPE boolean DEFAULT ' '
                      value(t_table) TYPE table .
      
          CLASS-METHODS: double_click FOR EVENT double_click OF cl_salv_events_table
                      IMPORTING row column.
      
      ENDCLASS.                    "my_cl_salv_pop_up DEFINITION
      *----------------------------------------------------------------------*
      *----------------------------------------------------------------------*
      CLASS my_cl_salv_pop_up IMPLEMENTATION .
      
        METHOD popup .
      
          DATA: ob_salv_table TYPE REF TO cl_salv_table.
      
          TRY.
              cl_salv_table=>factory(
                IMPORTING
                  r_salv_table = ob_salv_table
                CHANGING
                  t_table      = t_table ).
      
            CATCH cx_salv_msg.
          ENDTRY.
      
          CHECK ob_salv_table IS BOUND.
      
          ob_salv_table->set_screen_popup(
            start_column = start_column
            end_column   = end_column
            start_line   = start_line
            end_line     = end_line ).
      
          DATA: ob_salv_events    TYPE REF TO cl_salv_events_table.
      
          ob_salv_events = ob_salv_table->get_event( ).
      
          SET HANDLER double_click FOR ob_salv_events .
      
          ob_salv_table->display( ) .
      
        ENDMETHOD .                    "popup
      *----------------------------------------------------------------------*
        METHOD double_click .
      
          st_double_click-row    = row .
          st_double_click-column = column .
      
        ENDMETHOD .                    "raise_double_click
      *----------------------------------------------------------------------*
      
      ENDCLASS.                    "my_cl_salv_pop_up IMPLEMENTATION
      
      *----------------------------------------------------------------------*
      
      START-OF-SELECTION .
        PERFORM at_start_of_selection .
      
      *----------------------------------------------------------------------*
      *----------------------------------------------------------------------*
      FORM at_start_of_selection .
      
        DATA it_sflights TYPE TABLE OF sflights.
      
        SELECT * INTO TABLE it_sflights
        FROM sflights UP TO 100 ROWS .
      
        my_cl_salv_pop_up=>popup( EXPORTING t_table = it_sflights  )  .
      
        MESSAGE s000(oo) WITH
          my_cl_salv_pop_up=>st_double_click-row
          my_cl_salv_pop_up=>st_double_click-column .
      
      
      ENDFORM.                    "at_start_of_selection
      
      
      Author's profile photo Ahmad Feisal Abdul Halim
      Ahmad Feisal Abdul Halim

      Hi,

      Thank you.Very easy and useful.

      Author's profile photo Former Member
      Former Member

      Hi George;

      I tried to create the function in SE37 but when I want to activate the function,there is an error like below;

      Field "IT_ALV[]" is unknown. It is neither in one of the specified
      tables nor defined by a "DATA" statement . . . . . . . . . .

      Can you help about that ?

      Regards

      Fırtına

      Author's profile photo Ahmad Feisal Abdul Halim
      Ahmad Feisal Abdul Halim

      First click on Tabs Tables and fill in :

      IT_ALV TYPE  STANDARD
      TABLE

      Next, Tabs Import :

      I_START_LINE TYPE  I DEFAULT  6

      I_END_COLUMN TYPE  I DEFAULT  100

      I_END_LINE TYPE  I DEFAULT  10

      I_TITLE TYPE  STRING DEFAULT  'ALV'

      I_POPUP  TYPE  FLAG DEFAULT  '  '

      Author's profile photo Former Member
      Former Member

      Hi Feisal ;

      When I entered the Table tab like that;

      IT_ALV TYPE  STANDARD

      TABLE

      error mesaage : TABLES parameters are obsolete!


      Regards


      Author's profile photo Ahmad Feisal Abdul Halim
      Ahmad Feisal Abdul Halim

      Hi Firtina,

      Give you screenshots

      Capture1.JPGCapture.JPG

      Author's profile photo Former Member
      Former Member

      Feisal ;

      Thanks a lot.Now its working.

      Regards

      Author's profile photo santosh baratam
      santosh baratam

      Hi Yigit,

      It is just a Warning Message. You can go ahead by pressing an "enter".

      Please find SAP Documentation as follows, in regard to TABLES parameters,

      -     "TABLES parameters are table parameters. Table parameters are obsolete
      CHANGING parameters that are typed as internal standard tables with a header
      line. If an internal table without a header line or a table body is passed as an
      actual parameter to such a formal parameter, an empty header line is generated
      in the function module. If an internal table with a header line is used as an
      actual parameter, both the table body and the header line are passed to the
      function module. In the case of formal parameters defined with TABLES, no value
      transmission is possible.

      Formal parameters defined with TABLES can be replaced by formal parameters
      defined with CHANGING. A local work area can be created in the function
      module  for the internal table using the addition LIKE LINE OF itab of the DATA
      statement in the function module."

      Thanks,

      Santosh KB.

      Author's profile photo Former Member
      Former Member

      Good .. In a project with heavy ALV work .. This can cut out a lot of work..

      Author's profile photo Former Member
      Former Member

      Good, it's very simple, analog program SALV_DEMO_TABLE_REAL_SIMPLE

      Author's profile photo Ganu K
      Ganu K

      is it possible to add a hot spot inside the popup window and call a transaction ?

      Author's profile photo Binh Thai
      Binh Thai

      Hi Ganu, maybe you had the answer yourself but anyway...

      I just digged into it and I think it is possible to do such things. You can set a breakpoint and see it goes through the form USER_COMMAND etc.

      Author's profile photo Mohamed Hamdy
      Mohamed Hamdy

      IT'S WORKING
      THANK YOUUUUU 

      Author's profile photo Sergiu Iatco
      Sergiu Iatco

      Good example:

      SE38: DEMO_ALV_REPORTING

      Classical example:

      SE38: DEMO_CLASSICAL_REPORTING