Quantcast
Channel: SCN : All Content - ABAP for SAP HANA
Viewing all articles
Browse latest Browse all 831

Execute Procedure with i/o parameters from ABAP

$
0
0

Hello,

 

We are using HANA as secondary database and I need to execute HANA Procedures from ABAP.

 

I have created a procedure in HANA with a parameter as input and table as output.

 

I executed it in HANA as

 

CALL "_SYS_BIC"."xxx/RETREIVE_ZHMARA"('MT02',?)

 

and it worked fine.

 

 

but I'm not able to execute it from ABAP.

 

My need is to pass parameter as input and get the result in a internal table.

 

 

Following is my code:-

 

 

 

DATAstmt_ref    TYPE REF TO cl_sql_statement,

        con_ref     TYPE REF TO cl_sql_connection,

        res_ref     TYPE REF TO cl_sql_result_set,

        d_ref       TYPE REF TO data,

        d_ref1      TYPE REF TO data,

        lv_mtart    TYPE zhmara-mtart,

        output      TYPE i.

 

 

 

lv_mtart = 'MT02'.

 

     con_ref = cl_sql_connection=>get_connection( 'ABC' ).

     stmt_ref = con_ref->create_statement( ).

 

GET REFERENCE OF lv_mtart INTO d_ref.

 

         stmt_ref->set_param( data_ref = d_ref

                              inout    = cl_sql_statement=>c_param_in ).

 

        stmt_ref->execute_procedure( proc_name =

                                '"_SYS_BIC"."xxx/RETREIVE_ZHMARA"' ).


 

 

GET REFERENCE OF lt_zhmara INTO d_ref1.

                                           res_ref->set_param_table( d_ref1 ).


* Get the complete result set in the internal table

         output = res_ref->next_package( ).

 

         LOOP AT lt_zhmara INTO ls_zhmara.

           WRITE : /, ls_zhmara-mandt,

                      ls_zhmara-matnr,

                      ls_zhmara-ersda,

                      ls_zhmara-ernam,

                      ls_zhmara-laeda,

                      ls_zhmara-mtart,

                      ls_zhmara-matkl,

                      ls_zhmara-meins.

         ENDLOOP.


 

This works fine till  stmt_ref->execute_procedure   , sy-subrc = 0.

 

but gives a dump later as  'res_ref' is not initialized hence has ZERO value.

 

How can I set this?

 

** set_param_table for output parameter is only available in class cl_sql_result_set  but what should be the reference for its object res_ref??

 

 

Kindly suggest...


Viewing all articles
Browse latest Browse all 831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>