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

Define structure with table type fields using keyword "TYPES"

Former Member
0 Likes
9,824

Hi Gurus,

Using keyword "TYPES", I want to define a structure in which there is a field must be table type. It seems not allowed. For example:

TYPES tt_items TYPE TABLE OF sflight.

TYPES: BEGIN OF str,

field1 TYPE i,

field_tabl TYPE tt_items.

TYPES: END OF str.

Then I got a syntax error:

"TT_ITEMS" is a generic type. Use of this type is only possible for typing field symbols and formal parameters. -

What should I do if I want to have a table type field in it?

Thanks a lot.

Hi Gurus,

Using keyword "TYPES", I want to define a structure in which there is a field must be table type. It seems not allowed. For example:

TYPES tt_items TYPE TABLE OF sflight.

TYPES: BEGIN OF str,

field1 TYPE i,

field_tabl TYPE tt_items.

TYPES: END OF str.

Then I got a syntax error:

"TT_ITEMS" is a generic type. Use of this type is only possible for typing field symbols and formal parameters. -

What should I do if I want to have a table type field in it?

Thanks a lot.

10 REPLIES 10
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
5,199

I believe you have to do it like this.



TYPES: tt_items TYPE sflight OCCURS 0.

TYPES: BEGIN OF str,
       field1 TYPE i,
       field_tabl TYPE  tt_items,
       END OF str.

Regards,

RIch Heilman

Read only

0 Likes
5,199

Hi Heilman, thanks. But I have to put my types in a class, and "OCCURS" is not allowed in OO context.

Read only

0 Likes
5,199

OO how?class

Read only

0 Likes
5,199

Hi Heilman, thanks. But I have to put my types in a class, and "OCCURS" is not allowed in OO context.

Read only

gopi_narendra
Active Contributor
0 Likes
5,199

Do something like this...

TYPES : BEGIN OF ty_ekko.
INCLUDE  TYPE ekko.
TYPES : chk(1) TYPE c.
TYPES : END OF ty_ekko.

DATA : it_ekko TYPE STANDARD TABLE OF ty_ekko,
       is_ekko TYPE ty_ekko.

Regards

Gopi

Read only

0 Likes
5,199

Hi Gopi, I don't understand. How did you define type "ekko"? Thanks.

Read only

0 Likes
5,199

include type EKKO includes the whole strucutre of EKKO.

if you see the structure in debug mode, it_ekko contains the fields of EKKO as well as the field CHK of type C.

In your case you can do this


TYPES: BEGIN OF str.
INCLUDE TYPE sflight.  " includes whole structure of SFLIGHT
TYPES : field1 TYPE i. " include the field1 of type I
TYPES: END OF str.

DATA : it_str TYPE TABLE OF str, " internal table
       is_str TYPE str.          " work area

Regards

Gopi

Read only

varma_narayana
Active Contributor
0 Likes
5,199

Hii..

You can do this very much..

Change the code like this:

TYPES tt_items TYPE TABLE OF sflight.

TYPES: BEGIN OF str,

field1 TYPE i,

field_tabl TYPE LINE OF tt_items. "Component with a structurebased on table type

TYPES: END OF str.

<b>reward if Helpful</b>

Read only

suresh_muthusamy
Explorer
5,199
    TYPES:
BEGIN OF ty_equipments .
TYPES:
type TYPE string
.
TYPES: END OF ty_equipments .
TYPES:
tt_equipments TYPE STANDARD TABLE OF ty_equipments WITH DEFAULT KEY.
TYPES:
BEGIN OF data1 .
TYPES:
id TYPE string,
status TYPE string,
reject_reason TYPE string,
mileage TYPE string,
suggested_mode TYPE string,
equipments TYPE tt_equipments
.
TYPES: END OF data1 .

Read only

0 Likes
5,199

You have to use with DEFAULT Key when you declare a type of internal table.