Application Development 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: 

Length of a transparent table(structure)

Former Member
0 Kudos

Hi

I have the following table

say YYTAB...it has 2 fields of size 3 and 4.

How to find its total size?

I mean i shud get the output as 7.(Sum of the sizes of its fields)

is there any function module?

10 REPLIES 10

former_member194669
Active Contributor
0 Kudos

Check for table DD03L contains the output length . Make select in this table with table name as YYTAB and sum it up

0 Kudos

Thank you!

Former Member
0 Kudos

data : v_field1 like YYTAB-field1.

data : v_field2 like YYTAB-field2.

data : v_i type i,

v_i1 type i,

v_i2 type i.

describe field v_field1 length v_i1 in character mode .

describe field v_field2 length v_i2 in character mode .

v_i = v_i1 + v_i2.

write 😕 v_i.

former_member195698
Active Contributor
0 Kudos

Try this Fm

DD_TABL_LENGTH_GET

0 Kudos

@Srinivas.

Dude yu are really smart.. I hv jus given 2 fields to explain to everyOne. I have 40 fields in my table dude...which is of types c , n ,i etc...

I cannot keep on declaring the variables right?

0 Kudos

Hi,

another way:

TYPES: BEGIN OF lty_xyz,
...
       END OF lty_xyz.

DATA: ls_xyz TYPE lty_xyz.  
DATA: lv_length TYPE I.
DATA: lv_length_comp TYPE I.
FIELD-SYMBOLS <comp> TYPE ANY.
...


CLEAR lv_length.
DO.
  ASSIGN COMPONENT sy-index OF ls_xyz TO <comp>.
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.
  lv_length = lv_length + lv_length_comp. 
ENDD0.

Kind regards,

HP

former_member194797
Active Contributor
0 Kudos

The "describe field" command works also with the structure name. There is no need for a loop.

 describe field YYTAB length v_i1 in character mode 

0 Kudos

@Henry,

In Character mode isn t working. The table has both c and i fields... Its not unicode compatable rite?

0 Kudos

In this case ask it in byte mode:

describe field YYTAB length v_i1 in byte mode 

0 Kudos

@Henry.

But iam getting the length as twice...

say 14 instead of 7(taking above example) , if u use byte mode.