Всем доброго дня и хорошего настроения!
Столкнулся на днях со следующей задачей:
Необходимо подключаться к внешней БД MS SQL и запускать там хранимую процедуру.
В хранимку необходимо передать несколько параметров, среди которых есть таблица (как входной параметр).
Если убрать таблицу - процедура вызывается, всё отлично, но стоит добавить таблицу, как получаем ошибку:
"Operand type clash: int is incompatible with ContractNumTableType row 1, col -1"
ContractNumTableType - тип таблицы на внешней базе, структура которой состоит из одного поля типа int
Кто-нибудь сталкивался с подобным?
Буду признателен за любые советы.
Ниже код вызыва хранимки:
Code:
types: begin of ty_data,
contract_num type i,
end of ty_data,
tt_data type standard table of ty_data with empty key.
data: con_name type dbcon_name value 'CONN1',
l_date_fr type sy-datum value '20141223',
l_date_to type sy-datum value '20141224',
l_return type i,
l_rows_proceed type i,
lt_contr type tt_data.
data: sql_error type ref to cx_sy_native_sql_error,
sqlerr_ref type ref to cx_sql_exception.
field-symbols: <fs> like line of lt_contr.
append initial line to lt_contr.
read table lt_contr assigning <fs> index 1.
<fs>-contract_num = 12345.
append initial line to lt_contr.
read table lt_contr assigning <fs> index 2.
<fs>-contract_num = 54321.
data connection type ref to cl_sql_connection.
try .
connection = cl_sql_connection=>get_connection( con_name = con_name ).
data(sql) = new cl_sql_statement( con_ref = connection ).
sql->set_param_table( ref #( lt_contr ) ).
sql->set_param( data_ref = ref #( l_date_fr )
inout = cl_sql_statement=>c_param_in ).
sql->set_param( data_ref = ref #( l_date_to )
inout = cl_sql_statement=>c_param_in ).
sql->set_param( data_ref = ref #( l_return )
inout = cl_sql_statement=>c_param_out ).
l_rows_proceed = sql->execute_procedure( 'dbo.UpdateSpecial' ).
connection->commit( ).
connection->close( ).
catch cx_sy_native_sql_error into sql_error.
e_error = sql_error->get_longtext( ).
if e_error is initial.
e_error = sql_error->get_text( ).
endif.
catch cx_sql_exception into sqlerr_ref.
e_error = sqlerr_ref->get_longtext( ).
if e_error is initial.
e_error = sqlerr_ref->get_text( ).
endif.
endtry.