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: 

The type of RETURNING parameter must be fully specified

Former Member
0 Kudos

Hello,

I want to program a locall class, a method to return a table of a local type:

TYPES:

BEGIN OF ty_line,

id TYPE char10,

txt TYPE string,

END OF ty_line,

ty_line_tt type standard table of ty_line.

...

CLASS cl_html DEFINITION FINAL CREATE PRIVATE.

PUBLIC SECTION.

CLASS-METHODS parse importing fdata type string_table

returning value(fmeta) type ty_line_tt.

ENDCLASS. "cl_rep DEFINITION

Got an error as in the subject. Does that mean that the table type MUST be declared in the ABAP dictionary?

Regards,

Michal

1 ACCEPTED SOLUTION

Former Member

Just for the information: full specification of an internal table type must contain a key specification. So the solution was in this case to declare the type or the internal table variable as:

... type standard table of ty_line with non-unique key id ...

Regards,

Michal

3 REPLIES 3

uwe_schieferstein
Active Contributor
0 Kudos

Hello Michal

Since your static method is PUBLIC you cannot use local types in its interface. The type of the RETURNING parameter must be public as well. Thus, you have to define it in the DDIC.

Alternatively, you could switch to the more flexible EXPORTING parameters. Or you could return you itab as data reference, e.g.:

*&---------------------------------------------------------------------*
*& Report  ZUS_LOCAL_CLASS                                             *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  zus_local_class                                             .


TYPES:

BEGIN OF ty_line,
id TYPE char10,
txt TYPE string,
END OF ty_line,

ty_line_tt TYPE STANDARD TABLE OF ty_line.





*---------------------------------------------------------------------*
*       CLASS cl_html DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS cl_html DEFINITION FINAL CREATE PRIVATE.
  PUBLIC SECTION.
    CLASS-METHODS parse IMPORTING fdata TYPE string_table
*    RETURNING value(fmeta) TYPE ty_line_tt.
    RETURNING value(data_obj) TYPE REF TO data.
ENDCLASS. "cl_rep DEFINITION



*---------------------------------------------------------------------*
*       CLASS cl_html IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS cl_html IMPLEMENTATION.

  METHOD parse.
*   define local data
    DATA:
      lt_line_tt    TYPE ty_line_tt.

    APPEND INITIAL LINE TO lt_line_tt.

    GET REFERENCE OF lt_line_tt INTO data_obj.

  ENDMETHOD.                    "parse

ENDCLASS.                    "cl_html IMPLEMENTATION

Regards

Uwe

Former Member

Just for the information: full specification of an internal table type must contain a key specification. So the solution was in this case to declare the type or the internal table variable as:

... type standard table of ty_line with non-unique key id ...

Regards,

Michal

Hello Michal

It is also possible to define a (non-specific) default key:

... TYPE STANDARD TABLE of ty_line
                                WITH DEFAULT KEY.

Regards

Uwe