on ‎2026 Jan 16 2:35 AM
Hello experts,
When I'm mapping HANA SQL script dataset to an ABAP itab, there is a length limitation with string type fields.
string_agg(t5.json_data, ' ' order by canum) as json_data "AS NVARCHAR
to_clob(string_agg( t5.json_data,'' order by canum ) "AS CLOB This function works correctly in the DBeaver query window, successfully returning a string with an actual field value length that exceeds 27,000 characters.
However, this function does not perform as expected when mapping a HANA dataset to an ABAP internal table.
It faces limitations, such as nvarchar being restricted to 5,000 characters and clob to 16,384 characters, resulting in the truncation of the actual field value.
The code is as follows:
types: begin of ty_data_in,
count type i,
enq_lck_arg type char50,
tstp type timestamp,
itfid type ze_itfid,
id type zfunc_log_id,
func_name type zfunc_log_data-func_name,
func_parameter type zfunc_log_data-func_parameter,
func_paramtype type zfunc_log_data-func_paramtype,
func_structure type zfunc_log_data-func_structure,
func_defaultval type zfunc_log_data-func_defaultval,
func_type type zfunc_log_data-func_type,
func_class type zfunc_log_data-func_class,
func_ref_class type zfunc_log_data-func_ref_class,
json_data type string,
proc type flag,
end of ty_data_in.
data: lt_data_in type table of ty_data_in with empty key,
lt_stmt type table of string,
l_stmt type string.
lt_stmt[] = value #( ( |with | )
( |t2 as (| )
( |select t1.note3 as enq_lck_arg,t1.tzntstmps_beg as tstp,t1.note1 as itfid,t1.id| )
( | from zfunc_log as t1| )
( | where t1.note1 { l_zrfcid }| )
( | and t1.erdat { l_erdat }| )
( | and t1.code in ('I')| )
( |),| )
( |t3 as (select t2.enq_lck_arg,sum( 1 ) as count from t2 group by t2.enq_lck_arg order by t2.enq_lck_arg),| )
( |t4 as (| )
( |select t2.enq_lck_arg,t2.tstp,t2.itfid,t2.id,t3.count| )
( | from t2| )
( | join t3 on t3.enq_lck_arg = t2.enq_lck_arg| )
( | order by t3.count,t2.enq_lck_arg,t2.tstp,t2.itfid,t2.id| )
( |)| )
( |select t4.count,t4.enq_lck_arg,t4.tstp,t4.itfid,t4.id,| )
( | t5.func_name,t5.func_parameter,t5.func_paramtype,t5.func_structure,t5.func_defaultval,t5.func_type,t5.func_class,t5.func_ref_class,string_agg( t5.json_data,' ' order by canum ) as json_data| )
( | from t4| )
( | join zfunc_log_data as t5 on t5.id = t4.id| )
( | group by t4.count,t4.enq_lck_arg,t4.tstp,t4.itfid,t4.id,t5.func_name,t5.func_parameter,t5.func_paramtype,t5.func_structure,t5.func_defaultval,t5.func_type,t5.func_class,t5.func_ref_class| )
( | order by t4.count,t4.enq_lck_arg,t4.tstp,t4.itfid,t4.id,t5.func_name,t5.func_parameter,t5.func_paramtype,t5.func_structure,t5.func_defaultval,t5.func_type,t5.func_class,t5.func_ref_class;| )
).
l_stmt = reduce #( init sum type string for wa in lt_stmt[] next sum = cond #( when sum is initial then wa else |{ sum }{ wa }| ) ).
perform frm_hana_exec_query tables lt_data_in[] using l_stmt."json_data string type still got length limit
form frm_hana_exec_query tables pt_data type table
using p_stmt type string.
data: l_s_dbindex type dbindex,
l_stmt type string,
lref_data type ref to data,
lref_stmt type ref to cl_sql_statement,
lref_rslt type ref to cl_sql_result_set.
field-symbols: <fs_data> type any.
try.
assign pt_data[] to <fs_data>.
l_stmt = p_stmt.
create object lref_stmt.
"lref_stmt->set_param( ref #( tabname ) ).
"lref_stmt->set_param( ref #( l_schema ) ).
lref_rslt = lref_stmt->execute_query( l_stmt ).
get reference of <fs_data> into lref_data.
lref_rslt->set_param_table( lref_data ).
lref_rslt->next_package( ).
lref_rslt->close( ).
catch cx_sql_exception into data(lref_sqlerr).
free: <fs_data>.
data(l_msg) = lref_sqlerr->get_longtext( ).
message |HANA QUERY ERROR: { l_msg }| type 'E'.
endtry.
endform.
Request clarification before answering.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.