2007 Nov 28 11:53 AM
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.
2007 Nov 28 12:02 PM
Hi,
do like this.
Data : lv_len type i.
lv_len = strlen(field1).
Regards,
PRashant
2007 Nov 28 11:56 AM
2007 Nov 28 12:02 PM
Hi,
do like this.
Data : lv_len type i.
lv_len = strlen(field1).
Regards,
PRashant
2007 Nov 29 8:23 AM
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.
2007 Nov 29 8:27 AM
hi, try the following code
DATA: FLD(8),
LEN TYPE I.
DESCRIBE FIELD FLD LENGTH LEN IN CHARACTER MODE.
2007 Nov 29 8:27 AM
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.
2007 Nov 29 9:43 AM