2024 May 20 9:00 AM
Hi, the length lengths of the structdescr->components table are doubled. how do I solve it?
SELECT lifnr, surbel, tedbf, eysbel, degkul, degtar, degsaa, iso_9001, iso_9001_t,
iatf_16949, iatf_16949_t, surbel_t, iso_14001, iso_14001_t, iso_45001,
iso_45001_t, iso_27001, iso_27001_t, iso_50001, iso_50001_t, iso_genel, iso_genel_t
FROM zbtmm_t_0001 WHERE ( ( iso_genel_t >= '20230101' AND iso_genel_t <= '20250101' ) OR
( iso_50001_t >= '20230101' AND iso_50001_t <= '20250101' ) OR
( iso_27001_t >= '20230101' AND iso_27001_t <= '20250101' ) OR
( iso_45001_t >= '20230101' AND iso_45001_t <= '20250101' ) OR
( iso_14001_t >= '20230101' AND iso_14001_t <= '20250101' ) OR
( surbel_t >= '20230101' AND surbel_t <= '20250101' ) OR
( iatf_16949_t >= '20230101' AND iatf_16949_t <= '20250101' ) OR
( iso_9001_t >= '20230101' AND iso_9001_t <= '20250101' ) ) INTO TABLE @DATA(lt_analok).
DATA(tabledescr) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( lt_analok ) ).
DATA(structdescr) = CAST cl_abap_structdescr( tabledescr->get_table_line_type( ) ).
DATA index TYPE i value 1 .
LOOP AT structdescr->components INTO DATA(component).
WRITE: / index , ' ' , component-name , ' ' , component-type_kind , ' ' , component-length.
index = index + 1.
ENDLOOP.
2024 May 20 11:50 AM - edited 2024 May 20 12:02 PM
It's the length in bytes, so in a Unicode system (all systems since ABAP 7.53) where each character is 2 bytes, you simply divide by 2 to get the number of characters (cl_abap_char_utilities=>charsize).
Do it only when it's a character-based type of course.
NB: a question title like "Length in RTTS is doubled" would be better than just "LENGTH".
EDIT: your question is not about "ABAP Connectivity", better choose "ABAP Development" in SAP Managed Tags.