Stored Procedure – Introduction
Stored Procedure are frequently used Objects in SAP HANA. Stored Procedures allows to group the SQL statement into a single block and can return data in the form of output parameters.
In Mixed modelling Scenario calling a Stored Procedure from SAP Application can also be a good approach. Below is one Scenario we have faced in our Project.
Scenario: We had created a S/4HANA Report based on a Transient Provider and when checking for InfoProvider report gives a System Generated Tech name 2H*.
The InfoProvider here is a calculation View and instead of its technical Name the report shows a system generated Name 2H*. This is not a meaningful Information for a BW Developer and to find out the actual name of the Calculation View leads to the below development
Solution:
The generated name 2H* is in ABAP layer metadata and the Actual Calculation View Name is present in the HANA Metadata.
Hence, we are looking for a solution which combines both ABAP and HANA to find the required meaningful information.
We end up creating a report in ABAP which inside looks in HANA database tables/views by calling a AMDP Script and HANA Stored Procedure.
For this solution a small set of development is required:-
1. A Stored Procedure to get the Meta data information of Calculation View.
2. An AMDP Class (created in ABAP Perspective) with Method to call the stored procedure.
3. ABAP Program (Main program) where user input the system generate calculation view name (2H*) and gets the actual Calculation View name. In this program we are calling the AMDP Class.
The Metadata of Calculation view is present in the Schema “_SYS_BI” view name “BIMC_ALL_CUBES”.
The below stored procedure will get the desired metadata information for all the calculation view present in the HANA system.
Stored Procedure:-
create procedure "_SYS_BIC"."user_space.shankpre::clv_tech_name" (
OUT tab_out table (
"NAMESPACE" nvarchar(256),
"OBJECT_NAME" nvarchar(512)) )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA _SYS_BIC
READS SQL DATA AS
/********* Begin Procedure Script ************/
BEGIN
tab_out = select
CATALOG_NAME as NAMESPACE,
CUBE_NAME as OBJECT_NAME
from
"_SYS_BI"."BIMC_ALL_CUBES" ;
END
/********* End Procedure Script ************/
This above Stored procedure will be called into SE38 Program via AMDP class.
Please find below SE38 ABAP program:-
REPORT ZBW_HCPR_CLV.
parameters: p_clv type c length 30.
types: begin of l_s_objxref_hana,
namespace type c length 256,
object_name type c length 512,
end of l_s_objxref_hana.
data: l_t_hana_xref type standard table of l_s_objxref_hana,
ip_name type rsinfoprov.
field-symbols: <ls_xref> like line of l_t_hana_xref.
ZCL_AMDP_CLV=>CLV_TECH_NAME( importing out_rows = l_t_hana_xref ).
loop at l_t_hana_xref assigning <ls_xref>.
call method cl_rodps_hana_model=>hash_odpname
exporting
i_package = <ls_xref>-namespace
i_name = <ls_xref>-object_name
receiving
r_odpname = ip_name .
concatenate '2H' ip_name into ip_name.
if
ip_name = p_clv.
write: / <ls_xref>-namespace, at 100 <ls_xref>-object_name.
endif.
endloop.
As you have noticed the statement in the above program, we are calling an AMDP class to get the data from Stored Procedure.
No comments:
Post a Comment