ABAP Programming Series – Part2 – ALV IDA
This article is part of the Valuable ABAP programming series for buddies series.
Simple and effective way of mass data retrieval on HANA database is Integrated Data Access using ALVs.
Create a CDS Entity called ZI_Tracks_ALV on top of the tracks database table.
Create a report and display Tracks using an ALV instance created with cl_salv_gui_table_ida=>create_for_cds_view(...)
.
The report may not contain any subroutine, but it must contain local classes to configure the ALV. For this time a simple local helper class embedded within an include file is OK.
Add select option to the selection screen to filter by Artist Name.
Create a class like zcl_track_virtual
and implement interface if_salv_ida_calc_field_handler
. The purpose of this class is to add calculated fields to the ALV which cannot be added in the CDS Entity.
Add an integer field called Rating and fill it with a random value from 1-5. Find the way to generate random numbers in ABAP from 1 to 5. Examine the importing parameters of if_salv_ida_calc_field_handler~calculate_line
what You need to implement beside get_calc_field_structure
. In case You need fields of the line for which You’re calculating fields ask it in method get_requested_fields
.
Use the zcl_track_virtual
class when instantiating the ALV to add the calculated Rating field to the output of the list report.
Enable free text search to find text particles in more text fields at once like Title and Artist. After successfully enabling this feature a new button – to flow down the a new free text search input field from the top of the table – will appear.
Share this content: