You are on page 1of 3

SQL-Script based Customer Exit for PAK Planning Functions on HANA.

Customers can implement own planning functionality by creating own planning function types and
assigning their own class to this planning function type. Such a class has to implement some
interfaces.

Starting from NW730 SP10 it is possible to implement customer planning logic in own SQL script
procedures which run in the HANA layer. Such procedures can be called by implementing the
Method TREX_EXECUTE in one of the following interfaces:

IF_RSPLFA_SRVTYPE_TREX_EXEC
IF_RSPLFA_SRVTYPE_TREX_EXEC_R

IF_RSPLFA_SRVTYPE_IMP_EXEC has to be implemented if no reference data shall be used


IF_RSPLFA_SRVTYPE_TREX_EXEC_R has to be implemented I reference data shall be available during
execution.

With NW740 once can also use ABAP managed database procedures to create SQL-Script.

Parameters for the SQL script procedure


The SQL script procedure must have an IN and an OUT table which have the structure of the
aggregation level. The procedure might have an additional table (with the same structure) which
contains the reference data (in case the interface IF_RSPLFA_SRVTYPE_TREX_EXEC_R was
implemented). Further the procedure might contain elementary IN parameters.

Infrastructure to Call SQL Script procedure


The SQL-script-procedure is called via the interface method:
if_rspls_sql_script->execute_sql_script.
This method has the following parameters:

I_VIEW Type Set to: i_view - importing parameter of


method TREX_EXECUTE
I_VIEW_REF Type Set to: i_view_ref - importing parameter of
method TREX_EXECUTE; in case you implement
IF_RSPLFA_SRVTYPE_TREX_EXEC_R
I_T_IOBJ_PARAM Type Each line in this table represents a parameter of
the SQL-script procedure. The fields are:
NAME Name of parameters
IOBJNM Info object (which defines the type of
the parameter)
VALUE value of the parameters
I_PROC_NAME Type SQL-Script-procedure name
I_R_MSG Type Ref To Set to: I_R_MSG - importing parameter of
method TREX_EXECUTE
R_RESULT_VIEW Type Move the value of the returning parameter to
r_s_view-view

An example how the method if_rsplfa_srvtype_trex_exec_r~trex_execute might be


implemented can look like this:
METHOD if_rsplfa_srvtype_trex_exec_r~trex_execute.
DATA: l_r_sql_script TYPE REF TO if_rspls_sql_script,
l_procedure_name TYPE string,
l_srvtypenm TYPE rsplf_srvtypenm,
l_t_iobj_param TYPE if_rsr_pe_adapter=>tn_t_iobj_param.

l_r_sql_script = cl_rspls_session_store_manager=>get_sql_script_instance( i_r_store = i_r_


store ).

* The method if_rspls_sql_script~get_parameter_values returns a table of parameters


* with the values given in the function definition
l_r_sql_script->get_parameter_values(
EXPORTING
i_r_param_set = i_r_param_set
i_para_name_for_procedure = 'HANA_PROCEDURE_NAME'
IMPORTING
e_procedure_name = l_procedure_name
e_t_iobj_param = l_t_iobj_param ).

* The function parameter given mehtod paramenter i_para_name_for_procedure


* will not be returned in the table e_t_iobj_param but the value of this
* function parameter will be returned int the mehtod parameter e_procedure_name
* This mechanisme can e.g. be used to define function specific HANA-procedure names.

* Other examples to get the name of the HANA-procedure name which will be called can be
* - you use the technical name of the planning function type:
l_srvtypenm = p_r_srv->get_srvtypenm( ).
l_procedure_name = l_srvtypenm.

* - or you simply give the HANA procedure name in a string:


l_procedure_name = 'MY_HANA_PROCEDURE'.

r_s_view-view = l_r_sql_script->execute_sql_script(
i_view = i_view
i_view_ref = i_view_ref
i_t_iobj_param = l_t_iobj_param
i_proc_name = l_procedure_name
i_r_msg = i_r_msg ).
ENDMETHOD. "IF_RSPLFA_SRVTYPE_TREX_EXEC_R~TREX_EXECUTE

Example for an implementation to call SQL script procedure


This example can be found in report RSPLS_SQL_SCRIPT_TOOL (please keep in mind that you have to
implement a public class in order to be able to assign the class to the planning function type in
transaction RSPLF1).

Blocking
Blocking has to be considered in the SQL script procedure itself.

Result table
The result table is treated as delta. So the values from the result table are aggregated to the original
values. This behavior is different from the behavior of the result table in the ABAP-Exit.

Tool Report
With the tool report RSPLS_SQL_SCRIPT_TOOL you can create the following Object on HANA

A table with the structure corresponding to the aggregation level. This table can be used to
give the type of the table parameters in your SQL script procedure
A body of the SQL script procedure. This procedure body contains the table parameters by
which data (on which the procedure shall operate) is passed and the returning table with the
procedure result. Additionally the elementary parameters from the function are listed with
the corresponding types.

Transportation of these objects between systems


In NetWeaver 7.30 and NetWeaever 7.31 you need to take care of transporting HANA Objects by
your own. With NetWeaver 7.4 onwards one can leverage ABAP managed database procedures to
transport them with other ABAP or BW objects using transport management system (transaction
STMS)

You might also like