Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 

How can I consume an analytical query in ABAP ?

Normally analytical queries are used with reporting tools like SAC, Analysis Office, WebDynpro Grid,  or RSRT in backend.

This post show how to directly access and use the query within your own ABAP application by the use of Lightweight BICS API ( LBA ) .

It's really easy and needs only 2 ABAP calls . Development was driven by the need for testing the query with unit test. But for sure this approach also fits to others usecase where you want to use the query in your ABAP application.

This example show the most simple case. Calling a query without variables.
DATA(lr_std_query) = NEW cl_lba_std_query( i_query_name = 'MyQueryName' ).

"EXPORTING i_t_requested_columns = lt_requested_columns "dimensions&keyfigures for resultset
" i_t_variable_values = lt_variable "mandatory and optional variables
" i_t_filter_values = lt_filter "additional filters
IMPORTING e_r_resultset = DATA(lr_resultset) "resultset table
                 e_t_column_catalog = DATA(lt_column_catalog) ). "resultset description

LBA comes also with a 2nd flavours to call the CDS based query.
DATA(lr_std_query) = NEW cl_lba_cds_query( i_view_name = 'MyCDSview' ). 

lr_cds_query->get_resultset(  ...


Query in this context means BW modelled queries:

  • CDS based analytical queries ,

  • Query modelled using BW modelling tools ( BWMT )

  • Query modelled using BEx Query Designer

Note 3269710 contain further details like available releases and has 2 attachments
with several sample cases for CDS based queries and classical analytical queries.