FALV -> Fast ALV Grid Object
Finally I’ve finished to work under FALV. You can find FALV classes in attachment and description under the links. But firstly let’s go through few following points:
- Why I’ve created FALV although SALV classes are provided by SAP?
I know SALV classes although I haven’t used them often. The main reason was that they don’t provide edit mode. So at the end I’ve always worked with cl_gui_alv_grid class so then whenever users decided that they need one of the field to be editable then I can do it in few seconds/minutes.
- But there is a way to make SALV editable!
Yes, I know the solutions of Naimesh Patel (found here) and Paul Hardy (in his ABAP to the Future book) and some other folks to make SALV editable. But In my own opinion, especially when you’re at least on 7.40 with SP5 making SALV editable is not needed as you can fast create ALV Grid which does everything you want. To be clear the big advantage of SALV, to call grid output of table in two, three lines when you goes to the code you’ll see it’s nothing more than call of REUSE_ALV_GRID_DISPLAY… really old FM, which at the end use CL_GUI_ALV_GRID. And yes I know about new SALV class for HANA, but that is another story…
- Direct reasons
As I used CL_GUI_ALV_GRID so often then I came up with an idea to do some class which will make the creation faster, but I never had time to do it at work. You may know it, because of the time pressure you choose to create report/program/solution in the way you’re doing from years … and then comes another task….and another….
So I’ve decided to do it at home…. yeah I’m crazy. But at least some of you can also use it.
- Advantages
- Fast CL_GUI_ALV_GRID creation
- Replacement of REUSE_ALV_GRID_DISPLAY and REUSE_ALV_GRID_DISPLAY_LVC for a simple editable reports to omit screen creation
- All events are already handled and with redefinition of method I can faster use it
- Faster setting of layout and field catalog attributes
- Easy switch and copy between popup, full screen and container version
- Easy toolbar handling (in grid and in full screen/popup using Dynamic GUI STATUS & TITLE with ABAP code )
- One place to handle user commands of full screen/popup call -> event user_command
- Prerequisites
I’ve worked on this on 7.40 SP8 but this should work also on SP5 as well. Sorry for the users bellow that versions but I’m so used to use new syntax that I couldn’t force myself to use old way of coding.
UPDATE: Thanks to Santi Moreno we have now 7.31 version, you can find it here as an attachment in blog with name ZFALV_V1.1.0.zip. Also GitHub repository is now available here https://github.com/fidley/falv so if you’d like to join us, you’re more than welcomed.
- Source code
Always updated source code in NUGG files and examples of usage will be available on my blog -> abapblog.com/falv . Bellow you can find some example videos with usage of FALV.
I really encourage you to try it and give me your feedback about FALV.
Cheers
Łukasz
Hi Lukasz,
I have the same type of thing called 'Themed ALV', where you use a data base to them the alv grid and a wrapper around the alv grid class that takes away much of the grunt work. It saves many hours of programming.
Rich
Hi Richard,
exactly, it saves a lot of time. This is first version but I have some ideas how to make it better 🙂
Cheers
Łukasz
Consider:
A front end to design what your grid looks like (ie specify the layout, and the formatting in the field catalogs), Automatic handling of hotspots - again Table driven - use a table that specifies the data element, PID and transaction (it needs a primary and secondary data element and PID combo). For more that 2 PID's allow it to have multiple lines for the same data element and sum those up.
Then init your hotspot table by looking at the data elements in the field catalog (making sure all fields mentioned for the hotspot are there), in the field catalog set the hotspot field.
Auto colouring using colour schemes - take over from the 'Zebra' auto output and use brighter colours. Check the CFIELDNAME and QFIELDNAME fields in the field catalog. If they are populated then colour the fields red or green etc. Handle the events and allow further redefinitions
Create a standard header that outputs the parameters and logo in a dynamic document.... I can implement something like the below very quickly. It goes on and on! Fun while you're writing it, easy to create good AVL grids when it's done!.
Good luck and keep going!
Rich
Oh and PS... Don't forget to reduce the time delay for the DELAYED_CHANGE and DELAYED_CHANGE_SELECTION callbacks - makes the grid a lot snappier.
Thanks Richard,
for sure I'll try some of your hints!
Cheers
Łukasz
Did you have a look at this:
(Full report example which shows full editable alv / just defined columns editable)
Long story short:
*** Create ALV with SALV class ***
DATA: gr_alv TYPE REF TO cl_salv_table.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = lt_tab ). "some internal table...
*** Get CL_GUI_ALV_GRID object of SALV ***
FIELD-SYMBOLS: <lr_grid> TYPE REF TO cl_gui_alv_grid.
DATA: lv_layout TYPE lvc_s_layo.
ASSIGN ('(SAPLSLVC)G_ALV') TO <lr_grid>.
IF sy-subrc = 0.
CALL METHOD <lr_grid>->get_frontend_layout
IMPORTING es_layout = lv_layout.
lv_layout-edit = abap_true.
CALL METHOD <lr_grid>->set_frontend_layout
EXPORTING is_layout = lv_layout.
CALL METHOD <lr_grid>->refresh_table_display( ).
ENDIF.
Yes, I've seen this way, also the others. But this does not suits me fully 🙂
Hello!
If it is OK with you I will add a link to this blog in the 2nd edition of my book. I will just add a paragraph our two at the end of my ALV chapter to mention what you have achieved and point the readers to have a look for themselves.
I managed to programmatically add toolbar ICONS to the SALV, and even get individual columns editable, but I could find no way of getting individual cells editable in a SALV report, as you have managed to do.
For that reason amongst others I have come to the conclusion your solution is better than mine, and I am not ashamed to admit it.
All I ever wanted was to have the benefits of the SALV (automatic generation of the field catalogue) with the benefits of the CL_GUI_ALV_GRID (editable) with the benefits of the "old fashioned" function modules (don't have to manually create a screen).
If I could not get 100% there myself (due to not being to edit individual cells), despite many attempts, then I am more than happy to adopt a solution which gives me everything want. It is not as if this is ever going to be provided in standard SAP, despite every single ABAP programmer begging for it for years.
Well done and Cheersy Cheers
Paul
Thanks Paul,
It would be an honour to me 🙂 If you can then once the 2nd edition is published please send me a copy in PDF 🙂 ( I already bought the first edition ).
Although I'm happy that I've created this classes then it would be better for whole community if SAP would adapt SALV instead.... but as you have shown and written many times, this may be never provided.
Cheers
Łukasz
Hi Lukasz,
do you mind if in my spare time I try to "downgrade" your code for poor fellows like me which works on older releases?
Obviously, I'll send you the rework (if I manage to do it) for your approval 🙂
Simone,
that would be really great! Maybe we should think about Github for that? But please start without it, and we can setup this later.
Cheers
Łukasz
I'll work as soon as I finish the Fiori course and a couple of non-SAP projects (like designing and building the kites with my kids 😀 ) I'm working on.
Hey - how about pop-bottle rockets ?? 😎
Hello Łukasz,
great work. Thank you very much!
I have a question.
If I want to use one of the added buttons, I implement a redefinition of method
evf_user_command.
How can I access the currently displayed table inside this method in an easy and clean way?
For example, if I wanted to send or print data from the table without leaving the alv grid.
I saw me->outtab, but it is of type ref to data.
Is there an easy way to access the the data with the correct structure?
What would you recommend?
Best regards,
Dominik
Thanks a lot Dominik!
As you know the type of your table then you can do following:
field-symbols: <outtab> type tt_your_table_type.
assign outtab->* to <outtab>.
and now you can access your table with this field symbol.
Cheers
Łukasz
Thank you very much again, Łukasz!
I did not see this solution.
Best regards,
Dominik
Hello Łukasz,
I'm with the following difficulty, created the ZSAPLINK_INSTALLER program and follow all the steps of your blog to create the classes for FALV. What happens is that only the calls of Zs functions are implemented, I need the source code to create functions: Z_FALV_MASS_REPLACE, Z_FALV_CALL_MASS_SS and Z_FALV_DISPLAY.
Best regards,
Alisson.
Hello Alisson,
you need to import whole function group ZFALV, which is included in the nugget. Maybe you don't have Saplink plugin for function groups?
Cheers
Łukasz
Łukasz,
Thank you for your help, I could do and liked the result, will further explore the features now. Very good.