SAP ABAP on HANA: Part XVIII. SALV IDA (Integrated Data Access)

0
82
ABAP on SAP HANA

SAP ALV Integrated Data Access

Contents

Introduction.
Program Construct
Step – I:  Design Selection Screen
Step – II: Design Local Class for SALV IDA implementation
Step – III: Call SALV IDA Factory
Step – IV: Handle Selection Screen Select Options
Step – V: Handle Calculated Fields
     Implement the “get_calc_field_structure”
     Implement “get_requested_fields”
     Implement “calculated_line”
     Implement “Start_Page” and “End_Page”
     Set the heading text of newly added column
Step VI – Handle Hotspot Event
Step VII – Handle Toolbar Button (Button Function)
Step VIII – Adding Text Search Functionality
Step IX – ALV Title
Step X – Add Zebra Patter
Step XI – Add Full Screen Control
Output.

Introduction

Handling huge amount of data of a table often leads to the performance bottleneck. SAP offers a new version of ALV to deal with the large quantity of data to be displayed on UI resulting improved response for operations like sorting, aggregation or filtering etc. The table below shows the advantages of SALV IDA over traditional SALV.

SALV IDA vs SALV

Program Construct

Step – I:  Design Selection Screen

We are going to use T100 table for this SALV IDA. Our selection screen should look like this –SALV IDA

Necessary coding has been done in a separate include – YSASWATA_SALV_IDA_TOP

Integrated Data Access

Step – II: Design Local Class for SALV IDA implementation

We are going to create a separate include which will hold our local classes and related implementations.

SALV IDA implementation

At this point, our prime concern is METHOD – “add_sel_cond” as this will create the factory subsequent to which we will have our other method accesses.  Note the importing parameters are message number(s_msgnr) and application area(s_arbgb) since we are passing only these two selection screen select-options and want our data to be filtered on the value passed by the user. You can pass your own select-options as per your requirement.

Also Read: Write your first Z Program in SAP HANA.

Step – III: Call SALV IDA Factory

Now let’s see the factory creation method –

how to call SALV IDA Factory

Call the CREATE method of the class – CL_SALV_GUI_TABLE_IDA .  At this stage, we can only pass iv_table_name and receive lo_salv_ida (we will come to io_calc_field_handler at a later stage of this document).

Step – IV: Handle Selection Screen Select Options

Since we have select options on the selection screen, we need our table to fetch data from HDB considering the select options values provided. For this, we need to pass the select options to cl_salv_range_tab_collector class. With the object created, we can access add_ranges_for_name method for adding select-options.

fetch data from HDB

Once the add_ranges_for_name for all the select-options are done, we need to collect them through get_collected_ranges method in li_range_pair table.

Call set_select_options method of if_salv_gui_table_ida to set the select-options to be processed and pass li_range_pair.

Also Check: An ABAPers first SAPUI5 App (lessons learned)

NOTE: You can also add hard conditions just by creating a reference otocondition factory.

salv

Step – V: Handle Calculated Fields

Although we cannot have our own table to be passed to utilize the power of SALV, we can surely add some columns to our final SALV IDA structure based on the derived calculation from existing fields. In this example, we will add two custom calculated columns which essentially hold the count of ‘&’ and uppercase form of the message text present in column ‘TEXT’. You can add your own logic and add as many columns as you want.

To achieve this we need to create a local class and incorporate the if_salv_ida_calc_field_handler interface.

if_salv_ida_calc_field_handler

NOTE: I have created a new type (ty_new_fields) of the enhanced structure we are going to use.

Implement the “get_calc_field_structure”

Implement “get_requested_fields”

salv ida

Implement “calculated_line”

if_salv_ida_calc_field_handler

 Implement “Start_Page” and “End_Page”

Integrated Data Access

Finally we need to pass this if_salv_ida_calc_field_handler reference to SALV factory to have this functionality available in our SALV.

Set the heading text of newly added column

io_calc_field_handler

Step VI – Handle Hotspot Event

Create an event method to handle the hotspot functionality.

Handle Hotspot Event

Upon clicking on the hotspot, the row details will be shown. To achieve this functionality we need to introduce the if_salv_gui_selection_ida interface to fetch all field information.  To display all fields we can make use of the cl_salv_ida_show_data_row=>display class and method.

Hot Spot in SLAV IDA

Step VII – Handle Toolbar Button (Button Function)

Like any other SALV, it is absolutely possible to add buttons to the application toolbar and plug in custom functionality upon clicking on them.

Create a method (button_selected) of event “Function_Selected” which can be found in if_salv_gui_toolbar_ida.

Handle Toolbar Button

“EV_FCODE” should hold the button function code. Remember to check whether any row is selected or not. Without this condition, if the user clicks on the button without selecting any row subsequent code will be triggered.

Handle Toolbar Button

Note – ‘GET_SELECTED_ROW’ is for selecting a single row and ‘GET_SELECTED_RANGE’ is for selecting multiple rows.

You can add your functionality depending upon the value you get in ‘LI_NEW_LINE’ or ‘LI_NEW’.

HANA ABAP

To add the button, we need to use ‘ADD_BUTTON’. For adding separator use ‘ADD_SEPARATOR’. For selection mode of rows use ‘SET_SELECTION_MODE’.

Did you check? How to create your first OData Service?

Step VIII – Adding Text Search Functionality

We can add fuzzy search functionality in SALV IDA just with this simple technique.

Adding Text Search Functionality

Restriction – The field on which we want the text search should be a char/string field.

Step IX – ALV Title

You can add the title to the ALV with this one-liner code.

ALV Title

Step X – Add Zebra Pattern

Add Zebra Patter

Step XI – Add Full Screen Control

Add Full Screen Control

Output

Let’s check the final output of all the coding.

Selection Screen

integrated display access in HANA

ida salv demo

Text Search

FUZZY LOGIC

References

ZEVOLVING – By Naimesh Patel
SALV_IDA_TEST – sap package for IDA programs.

Hope this detailed article would guide you through your first SALV IDA Development. In case of any queries, please feel free to contact us.

If you GENUINELY like our articles then it would be a HUGE help if you shared, subscribed and liked us on facebookIt might seem insignificant, but it helps more than you might think.

Also, check our popular step by step tutorials on some of the important topics of SAP ABAP.

1. ABAP for SAP HANA Tutorials
2. ABAP Web Dynpro Tutorials
3. GOS Tutorial
4. OOPs ABAP Tutorial
5. HANA Tutorial
6. SAP Netweaver and OData Tutorial
7. SAP Adobe Form Tutorial
8. SAP Fiori Tutorial
9. SAPUI5 Tutorial
10. SAP Screen Personas Tutorials
11. SAP Workflow

LEAVE A REPLY

Please enter your comment!
Please enter your name here