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: 

error during deep structure definition

Former Member
0 Kudos

Hi Colleagues,

I want to define a type which is a deep structure in a class.something like this,

public section.

Types: begin of a,

name type char40,

end of a.

types: begin of b,

value1 type standard table of a,

value2 type of i,

end of b.

but i always got an error saying that,

'you cannot use generic type definitions within structures'

Can anyone help on this?

Thank you very much!

Best Regards,

Lei

1 ACCEPTED SOLUTION

Former Member

Hello

Do this:


  PUBLIC SECTION.
    TYPES:
      BEGIN OF a,
        name TYPE char40,
      END OF a,
      BEGIN OF b,
        value1 TYPE STANDARD TABLE OF a WITH NON-UNIQUE DEFAULT KEY,
        value2 TYPE i,
      END OF b.

When using ABAP Objects you need to declare the tables using a complete definition including the KEY to the standard table and in the TYPE i you don't need the OF.

Regards.

6 REPLIES 6

Former Member

Hello

Do this:


  PUBLIC SECTION.
    TYPES:
      BEGIN OF a,
        name TYPE char40,
      END OF a,
      BEGIN OF b,
        value1 TYPE STANDARD TABLE OF a WITH NON-UNIQUE DEFAULT KEY,
        value2 TYPE i,
      END OF b.

When using ABAP Objects you need to declare the tables using a complete definition including the KEY to the standard table and in the TYPE i you don't need the OF.

Regards.

matt
Active Contributor
0 Kudos

>

>

> When using ABAP Objects you need to declare the tables using a complete definition including the KEY to the standard table and in the TYPE i you don't need the OF.

>

> Regards.

Close.

When using return parameters or defining attributes in ABAP objects, they must be fully typed, which is as David says.

You must also use the fully typed specification for inner tables (deep structures) whether in objects or not.

In other contexts, include objects, at least in later versions, you can still use the non-full specification. But it's better not to.

former_member203501
Active Contributor
0 Kudos

sorry...

Former Member
0 Kudos

TYPES: BEGIN OF a,
name TYPE char40,
END OF a.

TYPES: BEGIN OF b.
INCLUDE TYPE a.
TYPES: value2 TYPE i,
END OF b.

matt
Active Contributor
0 Kudos

>

>


> TYPES: BEGIN OF a,
> name TYPE char40,
> END OF a.
> 
> TYPES: BEGIN OF b.
> INCLUDE TYPE a.
> TYPES: value2 TYPE i,
> END OF b.
> 

Wrong

Former Member
0 Kudos

we can use types like

1. TYPES { {dtype[(len)] TYPE abap_type [DECIMALS dec]}

| {dtype TYPE abap_type [LENGTH len] [DECIMALS dec]} }.

Refer to Existing Types

2. TYPES dtype { {TYPE [LINE OF] type}

| {LIKE [LINE OF] dobj} }.

Reference Types

3. TYPES dtype { {TYPE REF TO type}

| {LIKE REF TO dobj} }.

Structured Types

4. TYPES BEGIN OF struc_type.

...

{TYPES dtype ...} | {INCLUDE {TYPE|STRUCTURE} ...}.

...

TYPES END OF struc_type.

Table Types

5. TYPES dtype { {TYPE tabkind OF [REF TO] type}

| {LIKE tabkind OF dobj} }

[WITH key] [INITIAL SIZE n].

Ranges Table Types

6. TYPES dtype {TYPE RANGE OF type}|{LIKE RANGE OF dobj}

[INITIAL SIZE n].