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

Internal table

Former Member
0 Likes
909

Hi there,

How can I declare an internal table into another internal table type?

I'm trying this, but it's not working:

      • Textos

begin of ty_linhas ,

linha(255) ,

end of ty_linhas ,

begin of ty_textos ,

rsnum TYPE resb-rsnum ,

rspos TYPE resb-rspos ,

linhas type ty_linhas ,

end of ty_textos .

thanks,

Alexandre Nogueira

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
880

Are you trying to do this


TYPES: BEGIN OF ty_linhas,
        linha(255).
TYPES: END OF ty_linhas.

DATA: BEGIN OF ty_textos,
        rsnum  TYPE resb-rsnum,
        rspos  TYPE resb-rspos,
        linhas TYPE ty_linhas.
DATA: END OF ty_textos.

or this?


TYPES: BEGIN OF ty_linhas,
        linha(255).
TYPES: END OF ty_linhas.

DATA: BEGIN OF ty_textos,
        rsnum  TYPE resb-rsnum,
        rspos  TYPE resb-rspos,
        linhas TYPE TABLE OF ty_linhas.
DATA: END OF ty_textos.

Both are ok.

Srinivas

12 REPLIES 12
Read only

Former Member
0 Likes
880

Hi

      • Textos

TYPES: begin of ty_linhas ,

linha(255) ,

end of ty_linhas ,

GT_LINHA TYPE STANDARD TABLE OF TY_LINHAS

begin of ty_textos ,

rsnum TYPE resb-rsnum ,

rspos TYPE resb-rspos ,

linhas type GT_linhas ,

end of ty_textos .

Now the field LINHAS of type TY_TEXTOS is a table with the same structure of TY_LINHAS

Max

Read only

0 Likes
880

Nope, It's still not working.

Sorry

Read only

0 Likes
880

Hi

Please give us your code!

Max

Read only

0 Likes
880

my code is this, the same the first message that I wrote

      • Textos

begin of ty_linhas ,

linha(255) ,

end of ty_linhas ,

begin of ty_textos ,

rsnum TYPE resb-rsnum ,

rspos TYPE resb-rspos ,

linhas type ty_linhas ,

end of ty_textos .

The error ir here

the error is: You cannot use generic type definitions within structures.

Read only

Former Member
0 Likes
880

Hi ,

Try this.

      • Textos

begin of ty_linhas ,

linha(255) ,

end of ty_linhas ,

types : begin of ty_textos ,

rsnum TYPE resb-rsnum ,

rspos TYPE resb-rspos .

include type ty_linhas.

Types: end of ty_textos .

Read only

Former Member
0 Likes
881

Are you trying to do this


TYPES: BEGIN OF ty_linhas,
        linha(255).
TYPES: END OF ty_linhas.

DATA: BEGIN OF ty_textos,
        rsnum  TYPE resb-rsnum,
        rspos  TYPE resb-rspos,
        linhas TYPE ty_linhas.
DATA: END OF ty_textos.

or this?


TYPES: BEGIN OF ty_linhas,
        linha(255).
TYPES: END OF ty_linhas.

DATA: BEGIN OF ty_textos,
        rsnum  TYPE resb-rsnum,
        rspos  TYPE resb-rspos,
        linhas TYPE TABLE OF ty_linhas.
DATA: END OF ty_textos.

Both are ok.

Srinivas

Read only

0 Likes
880

Ok Sri, It really works, but this way, it's no longer a TYPE, it have become an object "ty_textos"

Read only

0 Likes
880
u can also use like this

DATA : BEGIN OF TY_TEXTOS,
         RSNUM TYPE RESB-RSNUM ,
          RSPOS TYPE RESB-RSPOS ,
          <b>BEGIN OF TY_LINHAS ,
            LINHA(255) ,
          END OF TY_LINHAS,</b>

END OF TY_TEXTOS .
Read only

0 Likes
880

Check this out

types: begin of t_tab4,

setid type t800s-setnr,

arbpl type crhd-arbpl,

charg type mseg-charg,

end of t_Tab4.

types: begin of t_tab3,

setid type t800s-setnr,

arbpl type crhd-arbpl,

charg type mseg-charg,

t_tab2 type t_tab4,

end of t_Tab3.

data: l_Tab3 type t_Tab3.

Read only

0 Likes
880

You define local types in your program to whatever complexity you want. You can have a simple type like

TYPE matnr(18). You can have a complex type like


TYPES: BEGIN OF ty_linhas,
        linha(255) OCCURS 10.
TYPES: END OF ty_linhas.

DATA: BEGIN OF ty_textos,
        rsnum  TYPE resb-rsnum,
        rspos  TYPE resb-rspos,
        linhas TYPE TABLE OF ty_linhas.
DATA: END OF ty_textos.

Here your type itself is a internal table and the structure that you later created is creating a complex field called 'linhas' which is an internal table of internal tables.

Type by itself cannot become an object holding data, unless it is used in the declaration of a data variable define using DATA statement.

I hope it is clear.

Srinivas

Read only

0 Likes
880

Yeap, it's clear, thanks all for the answers!!!

Alexandre Nogueira

Read only

Former Member
0 Likes
880

instead of TYPe use LIKe

linhas <b>LIKe</b> ty_linhas ,