09-25-2008 12:40 PM
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
09-25-2008 12:41 PM
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.
09-25-2008 12:41 PM
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.
09-25-2008 1:01 PM
>
>
> 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.
09-25-2008 12:41 PM
09-25-2008 12:45 PM
TYPES: BEGIN OF a,
name TYPE char40,
END OF a.
TYPES: BEGIN OF b.
INCLUDE TYPE a.
TYPES: value2 TYPE i,
END OF b.
09-25-2008 1:03 PM
>
>
> 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
09-25-2008 12:48 PM
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].