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:
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:
Best regards,
Georgiy Shlyahov
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......
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
Hi George ...
thanks for reply..
now its working....
Regards
vamc
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)...
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...
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
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:
You can use it like this:
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
The RECA class uses the SALV-OM to display the popup, not the GUI classes directly.
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
works for me on EHP7 for SAP ERP 6.0. thanks for the code its very useful.. bookmarking it
Hi George ;
It is very useful.Thanks.
Regards.
Özgün
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.
Hi,
Thank you.Very easy and useful.
Hi George;
I tried to create the function in SE37 but when I want to activate the function,there is an error like below;
Can you help about that ?
Regards
Fırtına
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 ' '
Hi Feisal ;
When I entered the Table tab like that;
IT_ALV TYPE STANDARD
TABLE
error mesaage : TABLES parameters are obsolete!
Regards
Hi Firtina,
Give you screenshots
Feisal ;
Thanks a lot.Now its working.
Regards
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.
Good .. In a project with heavy ALV work .. This can cut out a lot of work..
Good, it's very simple, analog program SALV_DEMO_TABLE_REAL_SIMPLE
is it possible to add a hot spot inside the popup window and call a transaction ?
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.
IT'S WORKING
THANK YOUUUUU
Good example:
Classical example: