Skip to Content
0
Apr 08, 2014 at 10:19 AM

Invalid column Index error - While consuming Calculation view via Native SQL

659 Views

Hi Experts,

I am trying to consume a Calculation view (sql script one) , which has input parameters, via Native SQL in a ABAP program .

Code snippet for the same would be as follows , Upon execution, it throws an error "Invalid Column Index (8) error " . Can anyone help what could be the issue here ?

Thanks in Advance,

Suma

REPORT ZTEST_HANA2.

*Report to consume Calculation view (script based) from ABAP

PARAMETERS: ip_docnr type BELNR_D,

ip_gjahr type GJAHR,

ip_bukrs type BUKRS,

ip_blgr type FAGL_RLDNR.

DATA: LO_SQL_STMT TYPE REF TO CL_SQL_STATEMENT,

LO_CONN TYPE REF TO CL_SQL_CONNECTION,

LO_RESULT TYPE REF TO CL_SQL_RESULT_SET,

LV_SQL TYPE STRING,

LR_DATA TYPE REF TO DATA.

DATA: LX_SQL_EXC TYPE REF TO CX_SQL_EXCEPTION,

LT_SEPMAPPS_CLSDINV TYPE TABLE OF SEPMAPPS_CLSDINV,

LV_TEXT TYPE STRING.

TRY.

lv_sql = |SELECT * FROM "_SYS_BIC"."DEMO-ABAP/CA_GET_FI_DATA" | &&

|WITH PARAMETERS ('placeholder'= ('$$p_DOCNR$$','{ ip_docnr }'),| &&

|'placeholder'=('$$p_GJAHR$$','{ ip_gjahr }')| &&

|,'placeholder'= ('$$S_BUKRS$$','{ ip_bukrs }')| &&

|,'placeholder'= ('$$p_base_ledger$$','{ ip_blgr }') )| .

LO_CONN = CL_SQL_CONNECTION=>GET_CONNECTION( ).

"Create an SQL statement to be executed via the connection

LO_SQL_STMT = LO_CONN->CREATE_STATEMENT( ).

"Execute the native SQL query

LO_RESULT = LO_SQL_STMT->EXECUTE_QUERY( LV_SQL ).

"Read the result into the internal table lt_sepmapps_clsdinv

GET REFERENCE OF LT_SEPMAPPS_CLSDINV INTO LR_DATA.

LO_RESULT->SET_PARAM_TABLE( LR_DATA ).

LO_RESULT->NEXT_PACKAGE( ).

LO_RESULT->CLOSE( ).

LO_CONN->CLOSE( ).

CATCH CX_SQL_EXCEPTION INTO LX_SQL_EXC.

LV_TEXT = LX_SQL_EXC->GET_TEXT( ).

MESSAGE LV_TEXT TYPE 'E'.

ENDTRY.