cancel
Showing results for 
Search instead for 
Did you mean: 

Pass input table parameter to HANA procedure through ADBC

former_member527468
Participant

Hi Experts,

We have a HANA procedure in the primary database which we are trying to access from ABAP using ADBC. The procedure has a table input parameter. We tried execute_query method of cl_sql_statement. However, the parameter binding does not work. Please find my code below. ( We are unable to replace this with an AMDP as the procedure is supposed to return a table of dynamic structure. Also I read that procedure proxy is no more recommended ).

PROCEDURE "xxxx"."xxxx::ztest_adbc_call"  ( in emp_nos table( emp_no nvarchar(10) ) ) 
	LANGUAGE SQLSCRIPT
	SQL SECURITY INVOKER 
	READS SQL DATA AS
BEGIN
select top 10 * from <table>; 
/* we have a dynamic query in the above statement's place */ 
END;

In ABAP,

report ZAJ_TEST_PROCEDURE_CALL.

types : begin of TY_EMP_NOS,
          EMP_NO type C length 10,
        end of  TY_EMP_NOS, TT_EMP_NOS type standard table of TY_EMP_NOS with default key.

data LO_STRUCTDESCR  type ref to CL_ABAP_STRUCTDESCR.
data : LO_TABLEDESCR type ref to CL_ABAP_TABLEDESCR.
data : DREF type ref to DATA.

    data(IN_EMP_NOS) = new TT_EMP_NOS( ( EMP_NO = '1' ) ( EMP_NO = '2'  ) ).
    data(SQL_STATEMENT) = new CL_SQL_STATEMENT( ).

try.

    SQL_STATEMENT->SET_PARAM_TABLE( IN_EMP_NOS ).
  catch CX_PARAMETER_INVALID into data(LX_PARAM_ERROR). " Superclass for Parameter Error
    break-point.

endtry.

try.

data(RESULT) = SQL_STATEMENT->EXECUTE_QUERY( |call "XXXX"."XXXXX::ztest_adbc_call"( emp_nos => ? )| ).

LO_STRUCTDESCR ?= CL_ABAP_STRUCTDESCR=>DESCRIBE_BY_DATA_REF(
             RESULT->GET_STRUCT_REF( RESULT->GET_METADATA( ) ) ).
LO_TABLEDESCR = CL_ABAP_TABLEDESCR=>CREATE( LO_STRUCTDESCR ).
create data DREF  type handle LO_TABLEDESCR.
RESULT->SET_PARAM_TABLE( ITAB_REF = DREF ).
RESULT->NEXT_PACKAGE( ).
catch CX_SQL_EXCEPTION into data(LX_SQL_EXCEPTION).
endtry.

This produces an exception with message invalid argument: Input parameter is inadequate as table parameter: line 1 col 56 (at pos 55)

Any suggestions please,

Thanks,

Ajith


DoanManhQuynh
Active Contributor
0 Kudos

I think you could create a temporary table in hana and use it as parameter of procedure. and maybe you could use AMDP instead of ADBC...

Accepted Solutions (0)

Answers (0)