Skip to Content
avatar image
Former Member

error during deep structure definition

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 25, 2008 at 11:41 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • >

      >

      > 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.

  • Sep 25, 2008 at 11:41 AM

    sorry...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 25, 2008 at 11:45 AM
    TYPES: BEGIN OF a,
    name TYPE char40,
    END OF a.
    
    TYPES: BEGIN OF b.
    INCLUDE TYPE a.
    TYPES: value2 TYPE i,
    END OF b.
    
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 25, 2008 at 11:48 AM

    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].

    Add comment
    10|10000 characters needed characters exceeded