Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Length report double

sanju_joseph
Product and Topic Expert
Product and Topic Expert
0 Likes
839

Hi,

I have the code below and i am not sure why the length of the attribute are reported double

Code:

FIELD-SYMBOLS:

<fs_comp_wa> TYPE abap_compdescr.

DATA: lr_desc_table type ref to CL_ABAP_TYPEDESCR,

lr_desc_struc type ref to cl_abap_structdescr.

lr_desc_table ?= cl_abap_typedescr=>describe_by_data( ZTEST).

if lr_desc_table->type_kind = 'u'. " <- Structure

lr_desc_struc ?= lr_desc_table.

loop at lr_desc_struc->components ASSIGNING <fs_comp_wa>.

"check the length of the field at run time '<fs_comp_wa>-length'

ENDLOOP.

endif.

Regards,

Sanju

6 REPLIES 6
Read only

Sm1tje
Active Contributor
0 Likes
731

You used 'ZTEST' as a test object. How is this object defined in the data dictionary? It's hard to reproduce without us knowing what this 'ZTEST' is all about.

Read only

Former Member
0 Likes
731

well you can try adding table and check this in your system .i understand behaviour will be same across the system

Read only

Sm1tje
Active Contributor
0 Likes
731

I did, I even tried several structures from DD, but they all seem to have a different TYPE_KIND (not equal to 'u').

Read only

Former Member
0 Likes
731

Well in my example ZTEST is the standard table , it;s really strange that even after adding a stucture you are not getting u,well what you can do next is to ignore the if condition and execute the remaining statement

Read only

Sm1tje
Active Contributor
0 Likes
731

lr_desc_table ?= cl_abap_typedescr=>describe_by_name( 'BUT000' ).

Descibe by data does not work for me, so I used statement above.

And that works just fine for me. No double entries.

Read only

Former Member
0 Likes
731

it;s really strange,why i am getting the issue,i have seen some blogs earlier on same issue and it looks to do with

unicode,i really didn;t understand what that has to do with length getting doubled ,but let me try your way and try

my luck