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

DESCRIBE FIELD statement difference between structure & Itab

Former Member
0 Likes
1,024

Hai ,

I am trying to read field attributes using DESCRIBE FIELD satement & I am getting the field type

in SYDES_DESC-types.

When I am trying to read the attributes of a structure like the one below,

data : begin of STRUCT ,

field1 type c,

field2 type c,

end of STRUCT.

and the table like below,

data : begin of TAB1 occurs 10,

field1 type c,

field2 type c,

end of TAB1.

that is ,

describe field STRUCT in w_sydes_desc.

describe field TAB1 in w_sydes_desc.

( w_sydes_desc is of type sydes_desc).

my question is,

for the above 2 stements the table W_SYDES_DESC-TYPES contains same values

though one is plain structure & another one is internal table with header line.

can any one tell how can we distinguish between the above fields?

or is ther any other approach to find wheter a variable is a struct or table?

Regards,

Bhaskar M

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
670

Hello,

describe field STRUCT in w_sydes_desc.

describe field TAB1 in w_sydes_desc.

When you use an int. table with HEADER LINE, then TAB1 represents the HEADER LINE & not the entire table body. To access the whole table you have to use TAB1[].

So you are getting the same results.

Try this coding:

TYPE-POOLS: sydes.

DATA : BEGIN OF struct ,
field1 TYPE c,
field2 TYPE c,
END OF struct.

DATA:
w_sydes_desc  TYPE sydes_desc,
w_sydes_desc1 TYPE sydes_desc.

DATA :
BEGIN OF tab1 OCCURS 10,
field1 TYPE c,
field2 TYPE c,
END OF tab1.

DESCRIBE FIELD struct INTO w_sydes_desc.
DESCRIBE FIELD tab1[] INTO w_sydes_desc1.

IF sy-subrc = 0.
WRITE: 'Hurray !!!'.
ENDIF.

BR,

Suhas

3 REPLIES 3
Read only

Former Member
0 Likes
670
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
671

Hello,

describe field STRUCT in w_sydes_desc.

describe field TAB1 in w_sydes_desc.

When you use an int. table with HEADER LINE, then TAB1 represents the HEADER LINE & not the entire table body. To access the whole table you have to use TAB1[].

So you are getting the same results.

Try this coding:

TYPE-POOLS: sydes.

DATA : BEGIN OF struct ,
field1 TYPE c,
field2 TYPE c,
END OF struct.

DATA:
w_sydes_desc  TYPE sydes_desc,
w_sydes_desc1 TYPE sydes_desc.

DATA :
BEGIN OF tab1 OCCURS 10,
field1 TYPE c,
field2 TYPE c,
END OF tab1.

DESCRIBE FIELD struct INTO w_sydes_desc.
DESCRIBE FIELD tab1[] INTO w_sydes_desc1.

IF sy-subrc = 0.
WRITE: 'Hurray !!!'.
ENDIF.

BR,

Suhas

Read only

Former Member
0 Likes
670

This message was moderated.