0% found this document useful (0 votes)
414 views2 pages

Calling Procedure in ABAP Using ADBC

This document describes calling a stored procedure reportSalesProdEXT using ABAP Database Connectivity (ADBC). It passes a category parameter to the procedure, retrieves the output table into a reference variable, selects from that table, and displays the results. Any SQL exceptions are caught and written to the log.

Uploaded by

vivian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
414 views2 pages

Calling Procedure in ABAP Using ADBC

This document describes calling a stored procedure reportSalesProdEXT using ABAP Database Connectivity (ADBC). It passes a category parameter to the procedure, retrieves the output table into a reference variable, selects from that table, and displays the results. Any SQL exceptions are caught and written to the log.

Uploaded by

vivian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

create procedure reportSalesProdEXT(in cat varchar(80),

out et_sales
table(currency_code varchar(4), gross_amount decimal(15,2)))
language sqlscript
default schema "SAPHANADB"
as begin
declare cnt integer;
declare i integer;
lt_products = select NODE_KEY from snwd_pd where category = :cat;

et_sales = select currency_code, sum( gross_amount ) as gross_amount


from snwd_so_i where product_guid in ( select node_key from
:lt_products )
group by currency_code;

cnt := RECORD_COUNT(:et_sales);
:et_sales.insert(('INR',80000),cnt + 1);
for i in 1..:cnt do
et_sales.GROSS_AMOUNT[:i] := :et_sales.GROSS_AMOUNT[:i] + 20000;
end for;
end;

*&---------------------------------------------------------------------*
*& Report zcall_procedure_adbc
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zcall_procedure_adbc.

types: begin of ty_proc_res,


variable type string,
table type string,
end of ty_proc_res,
begin of ty_data_res,
currency_code type snwd_so-currency_code,
gross_amount type snwd_so-gross_amount,
end of ty_data_res.

data: lt_proc type table of ty_proc_res,


lt_data type table of ty_data_Res,
lr_proc type ref to data,
lr_data type ref to data.

get reference of lt_proc into lr_proc.


get reference of lt_data into lr_data.

parameters : p_cat type snwd_pd-category.

try.
"ADBC - ABAP Database Connectivity
data(lo_conn) = cl_sql_connection=>get_connection( ).
data(lo_statement) = lo_conn->create_statement( ).
data(lv_statement) = |call reportSalesProdEXT('{ p_cat }',null) with overview|.
data(lo_result_set) = lo_statement->execute_query( statement = lv_statement ).
lo_result_set->SET_PARAM_TABLE(
EXPORTING
ITAB_REF = lr_proc
).
lo_result_set->next_package( ).
read table lt_proc into data(ls_proc) index 1.
lv_statement = |select * from { ls_proc-table }|.
write : / lv_statement .

lo_result_set = lo_statement->execute_query( statement = lv_statement ).


lo_result_set->SET_PARAM_TABLE(
EXPORTING
ITAB_REF = lr_data
).
lo_result_set->next_package( ).

cl_demo_output=>DISPLAY_DATA(
EXPORTING
VALUE = lt_data
* NAME =
).

lo_result_set->close( ).

catch cx_sql_exception into data(lo_ex).


write : / lo_ex->get_text( ).
endtry.

You might also like