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

Class types multi level table

Former Member
0 Likes
502

Hello everyone

I need to create a type in a customized class that will be used to have multi level table.

The first type is the structure of the final table. Inside that structure there is a field that is type table of string:

TYPES: BEGIN OF ty_data,
        Extension TYPE CHAR04,
        Delimiter TYPE CHAR01,
        line      TYPE TABLE OF string,
       END OF ty_data.
       
TYPES: lt_data TYPE TABLE OF ty_data.

The problem is when I am creating the TYPE ty_data, the system give me the following error message.

"You cannot use generic type definitions within structures"

Is anyone have an idea on how I can have that king of structure definition inside a class?

I even try to have something like:

TYPES: ty_string TYPE TABLE OF string.
TYPES: BEGIN OF ty_data,
        Extension TYPE CHAR04,
        Delimiter TYPE CHAR01,
        line      TYPE ty_string,
       END OF ty_data.
       
TYPES: lt_data TYPE TABLE OF ty_data.

That doesn't work either.

any suggestion?

Regards

DSTJ

2 REPLIES 2
Read only

prasenjit_sharma
Active Contributor
0 Likes
445

Hi,

I tried this.

TYPES: ty_string TYPE TABLE OF string.

DATA : BEGIN OF ty_data,

extension TYPE char04,

delimiter TYPE char01,

line TYPE ty_string,

END OF ty_data.

TYPES: lt_data LIKE TABLE OF ty_data.

And it worked.

Regards

Prasenjit

Read only

0 Likes
445

Hello Prasenjit

Thank you for your answer.

But it will not work. We cannot use "LIKE" in unicode programming into a class.

But I found the solution. I need to use an already existing table type

types: BEGIN OF TY_DATA,
           extension   TYPE CHAR04,
           delimiter   TYPE CHAR01,
           lines       TYPE SCR_STRINGS,
       END OF TY_DATA .

The type SCR_STRINGS exist into the SAP dictionary.

Now I can create a variable that is:

DATA: lt_data TYPE TABLE OF ty_data.

Regards

dstj