OIA With ADBC

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

*&---------------------------------------------------------------------*

*& Report zaug_oia_imodels


*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zaug_oia_imodels.

"Step 1: Create data type - parking space


types: BEGIN OF ty_oia,
company_name type snwd_bpa-company_name,
bp_id type snwd_bpa-bp_id,
open_days type int4,
gross_amount type snwd_so_inv_head-gross_amount,
currency_code type snwd_so_inv_head-currency_code,
END OF ty_oia.

data: itab type table of ty_oia,


wa type ty_oia,
lv_query type string,
lr_result type ref to data.

PARAMETERS p_curr type snwd_so_inv_head-currency_code.

get REFERENCE OF itab into lr_result.

lv_query = |SELECT COMPANY_NAME, BP_ID, ROUND(AVG(OPEN_DAYS),0) AS OPEN_DAYS,| &&


|SUM(CONV_GROSS_AMOUNT) AS GROSS_AMOUNT, CONV_GROSS_AMOUNT_CURRENCY AS
CURRENCY_CODE | &&
|FROM "_SYS_BIC"."AUG_ANUBHAV/CV_OIA"('PLACEHOLDER'=('$$P_CURR$
$','{ p_curr }')) | &&
|GROUP BY COMPANY_NAME, BP_ID, CONV_GROSS_AMOUNT_CURRENCY|.

data(lo_timer) = cl_abap_runtime=>create_hr_timer( ).
data(t1) = lo_timer->get_runtime( ).

try.
"Step 2: Create object of ADBC Class
data(lo_connection) = cl_sql_connection=>get_connection( ).

"Step 3: Create Statement object


data(lo_statement) = lo_connection->create_statement( ).

"Step 4: Set query for execution to statement object


data(lo_resultset) = lo_statement->execute_query(
statement = lv_query
).

"Step 5: Where is my parking, spefiy the internal table in which data will be
kept
lo_resultset->set_param_table(
EXPORTING
itab_ref = lr_result
).

"Step 6: Shoot - Trigger the query to HANA


lo_resultset->next_package( ).

"Step 7: Close the connection


lo_resultset->close( ).
catch CX_SQL_EXCEPTION into data(lo_ex).

WRITE : / lo_ex->get_text( ).

ENDTRY.

data(t2) = lo_timer->get_runtime( ).
data(t3) = ( t2 - t1 ) / 1000.

cl_demo_output=>display(
EXPORTING
data = itab
name = |Time takes was { t3 } ms|
* exclude =
* include =
).

*&---------------------------------------------------------------------*
*& Report zaug_oia_view_proxy
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zaug_oia_view_proxy.

select bp_id, company_name, open_days as open_days,


sum( conv_gross_amount ) as gross_amount,
conv_gross_amount_currency as currency_code
from ZVP_AUG_OIA
GROUP BY bp_id, company_name, conv_gross_amount_currency, open_days
order by company_name into table @data(itab) .

cl_demo_output=>display_data(
EXPORTING
value = itab
* name =
* exclude =
* include =
).

You might also like