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

problem while reading structure of table

Former Member
0 Likes
1,055

data : it_tabdescr type abap_compdescr_tab,

wa_tabdescr type abap_compdescr.

data : ref_table_descr type ref to cl_abap_structdescr.

  • Return structure of the table.

ref_table_descr ?= cl_abap_typedescr=>describe_by_name( 'MARA' ).

it_tabdescr[] = ref_table_descr->components[].

it_tabdescr[] contains following fields..

length TYPE i,

decimals TYPE i,

type_kind TYPE abap_typekind,

name TYPE abap_compname,

The code is working fine in 4.7..

But in ecc 6 length wise it is reading twice from table mara.

in 4.7 mandt length 3

ecc6 mandt length 6.

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
1,005

But in ecc 6 length wise it is reading twice from table mara.

This is because 4.7 is non-unicode system, while ECC 6.0 is unicode system.

In in non-Unicode 1char = 1byte, in Unicode 1 char = 2bytes. That's why you get the length doubled.

Regards

Marcin

8 REPLIES 8
Read only

MarcinPciak
Active Contributor
0 Likes
1,006

But in ecc 6 length wise it is reading twice from table mara.

This is because 4.7 is non-unicode system, while ECC 6.0 is unicode system.

In in non-Unicode 1char = 1byte, in Unicode 1 char = 2bytes. That's why you get the length doubled.

Regards

Marcin

Read only

0 Likes
1,005

How to over come with this problem.

i need the all fields name with their length and type by using the table name.

Read only

0 Likes
1,005
DATA: DDFIELDS TYPE DDFIELDS ,
      WA_DDFIELDS LIKE LINE OF DDFIELDS.

CALL FUNCTION 'TR_NAMETAB_GET'
  EXPORTING
    IV_TABNAME                       = 'MARA'
   IV_GET_LENGTHS_IN_CHARMODE       = 'X'
 IMPORTING
   ET_DFIES                         = DDFIELDS
 EXCEPTIONS
   NOT_FOUND                        = 1
   OTHERS                           = 2.
IF SY-SUBRC <> 0.
ELSE.
  LOOP AT DDFIELDS INTO WA_DDFIELDS.
    WRITE: / WA_DDFIELDS-FIELDNAME, WA_DDFIELDS-LENG,  WA_DDFIELDS-DATATYPE.
  ENDLOOP.
ENDIF.
Read only

0 Likes
1,005

The approach you took is correct one. in ECC just loop through the it_tabdescr[] and divide the length by 2.

Regards

Marcin

Read only

0 Likes
1,005

By using this Fm TR_NAMETAB_GET.. its of no use. the length is twice the actual length. please help me out with another solution

Read only

0 Likes
1,005

In my table currency field length is 13.. it shows only 7.. Then how to over come this problem

Read only

0 Likes
1,005

Hi Marcin,

When divide by 2, it will give wrong value for Type 'P', etc ie. VOLUM. Correct me if I am wrong.

Kanagaraja L

Read only

Kanagaraja_L
Active Contributor
0 Likes
1,005

Yes. Instead of You can use FM TR_NAMETAB_GET