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: 

Getting field lengths of an internal table field

former_member810660
Participant
0 Kudos
156

Hi Experts,

i have a small requirement like this below. Regarding dynamically generating an internal table.

 DATA: BEGIN OF itab OCCURS 10, 
       field1 type c,
       field2 like mara-matnr,
      END OF itab,

This is an internal table in my program, i have read these lines into another internal table, now i have to get the field lengths of field1 and field2. that means i should get the field length of field1 as 1 ( as its default length is 1) and length of field2 as 18 ( mara-matnr).

Is there any simple way to code this logic. Please help me in this, points will be awarded for useful answers.

Thansk & Regards,

Poorna.

1 ACCEPTED SOLUTION

former_member386202
Active Contributor
0 Kudos
134

Hi,

do like this.

Data : lv_len type i.

lv_len = strlen(field1).

Regards,

PRashant

6 REPLIES 6

Former Member
0 Kudos
134

Use

data: lv_len type i.

lv_len = strlen( field1 ).

Lokesh

former_member386202
Active Contributor
0 Kudos
135

Hi,

do like this.

Data : lv_len type i.

lv_len = strlen(field1).

Regards,

PRashant

0 Kudos
134

Hi Lokesh,

Actually STRLEN can only determine type c or system field lenghts. But my question is actually this. please see the below example:

DATA: BEGIN OF itab OCCURS 10,
       date TYPE sy-datum,
       time TYPE sy-uzeit,
       matnr TYPE mara-matnr,
      END OF itab,
DATA: len TYPE i,
       len1 TYPE i,
       len2 TYPE i.
len = strlen( itab-date ).
WRITE: / len.
len1 = strlen( itab-matnr ).
WRITE: / len1.
len2 = strlen( itab-time ).
WRITE: / len2.

my output is coming like this:


  8
  0
  6

where as the actual lenght of mara-matnr is 18. i need to get the lengths of referenced element. i hope you got my point.

Thanks & Regards,

Poorna.

0 Kudos
134

hi, try the following code

DATA: FLD(8),

LEN TYPE I.

DESCRIBE FIELD FLD LENGTH LEN IN CHARACTER MODE.

0 Kudos
134

Hi,

DATA: BEGIN OF itab OCCURS 10,

date TYPE sy-datum,

time TYPE sy-uzeit,

matnr TYPE mara-matnr,

END OF itab.

DATA: len TYPE i,

len1 TYPE i,

len2 TYPE i.

<b>DESCRIBE FIELD itab-time LENGTH LEN</b>.

write len.

former_member810660
Participant
0 Kudos
134

Thanks for your help.