Skip to Content
Author's profile photo Jörg Knaus

“Excel Style” Database Analytics with 1 Line of ABAP Code

The new ALV with IDA (Integrated Data Access)  is able to process a high number of records withouth negative impact on performance. this works for HANA but also for non-hana Databases (except for the Fuzzy Search feature which only works with column based tables)

basically the IDA reads only the records from the database, which are shown on the screen, as soon as the user scrolls down or defines a filter column, the database is reloading this slice of records.

(remember: the old alv was like select * into itab so loading all records into application server memory and from there to the gui)

this way i can show a big table like bseg or vbap with millions of records in a second:

ALV.gif

and from there, the user can define filters, groups, sum/total columns, sorting, exel export etc

all this can be done with an abap report with only 1! line of code: (*method fullscreen is available from 7.40 SP5, IDA class is available from 7.40 SP0)

REPORT Z_ALV_HANA. cl_salv_gui_table_ida=>createiv_table_name = ‘VBAP‘ )->fullscreen( )->display( ).

i added some features to have a little more comfort: Dynamic Table Name, Title with number of records, possibility to Save ALV Layout Variants, Fuzzy Search

ALV_SELECTION_SCREEN.gif

REPORT Z_ALV_IDA.

DATA layout  TYPE lvc_s_layo.

DATA columns TYPE lvc_t_fcat.

DATA column  TYPE lvc_s_fcat.

data lv_title type SYTITLE.

data: go_alv_display type ref to cl_salv_gui_table_ida.

DATA: ls_persistence_key TYPE if_salv_gui_layout_persistence=>ys_persistence_key.

data: lv_count type i.

parameters: p_tab(30) default ‘T000’.

parameters: p_sim type p length 2 decimals 1 default ‘0.8’.

parameters: p_search(50) lower case default ‘Walldorf’.

data: lo_alv type ref to IF_SALV_GUI_TABLE_IDA.

start-of-selection.

lo_alv = cl_salv_gui_table_ida=>createiv_table_name = p_tab ).

* create title test

   select count( * ) from (p_tab) into lv_count.

   write lv_count to lv_title. condense lv_title.

   concatenate p_tab ‘: number of records in table:’ lv_title  into lv_title separated by space.

   if p_search <> ‘ ‘.

   concatenate lv_title ‘,filtered by’ p_search into lv_title separated by space.

   endif.

lo_alv->display_options( )->set_title( lv_title ).   “#EC NOTEXT

* enable save of alv variants:

     concatenate syrepid ‘_’ p_tab into ls_persistence_keyreport_name.

*

     lo_alv->layout_persistence( )->set_persistence_options(

     EXPORTING

       is_persistence_key           = ls_persistence_key

       i_global_save_allowed        = ‘X’

       i_user_specific_save_allowed = ‘X’ “l_user_specific_save_allowed’

   ).

* Search Feature

if p_sim <> 0.

     lo_alv->text_search( )->set_field_similarity( p_sim ).

endif.

if p_search <> ‘ ‘.

     lo_alv->text_search( )->set_search_term( |{ p_search }| ).

endif.

     call method lo_alv->fullscreen( )->display( ).


to test the performance you can use table DD03L with 9 Millions of Records in an empty ERP System

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Powerful. Thanks for sharing.

      Best regards.

      Author's profile photo Former Member
      Former Member

      Im getting an error while executing this report

      Category               ABAP Programming Error

      Runtime Errors         GETWA_NOT_ASSIGNED

      ABAP Program           CL_SALV_IDA_STRUCTDESCR=======CP

      Application Component  BC-SRV-ALV

      Date and Time          12-26-2015 15:14:09

      Short Text

           Field symbol has not been assigned yet.

      What happened?

           Error in the ABAP Application Program

           The current ABAP program "CL_SALV_IDA_STRUCTDESCR=======CP" had to be

            terminated because it has

           come across a statement that unfortunately cannot be executed.

      Error analysis

           An attempt was made to access a field symbol that has not been assigned

           yet (data segment number "-1").

           That error occurs if

           - a typed field symbol is addressed before it has been set with ASSIGN,

           or

           - a field symbol is addressed that points to a row in an internal table

           that has been deleted, or

           - a field symbol is addressed that was previously reset using UNASSIGN,

           or that pointed to a local field that no longer exists, or

      Author's profile photo Joachim Rees
      Joachim Rees

      Interesting to see that this was used in 2014(!) already! I'm only start exploring cl_salv_gui_table_ida now!

      best
      Joachim