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: 

Internal table declaration

Former Member
0 Kudos

Hi all,

As per new versions, what is the best/correct way of declaring internal tables?

can anyone tell the syntax?

thanks

Revanth.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

TYPES: BEGIN of my_type,

field1(1),

field2(1),

END OF my_type.

DATA i_table like standard TABLE OF my_type.

DATA wa_table like my_type.

first declare type and declare internal table with out header line and work area

regards,

srinu reddy.

5 REPLIES 5

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try these ...


data: it_mseg type table of mseg,
      it_mkpf type table of mkpf.
 
data: wa_mseg type mseg,
      wa_mkpf type mkpf.

or

types: begin of ty_itab,
         <your fields>.
        end of ty_itab.

data: itab type table of ty_itab,
      wa_itab type ty_itab.

Regards,

Ferry Lianto

Former Member
0 Kudos

hi,

Corrrect way of declaration? what do u mean by this.

ways to declare internal tables.

1) if you want to create a intenal table same as a standard table in the database then

data : itab like standard table of vbak with header line.

2) if you want to have your own structure to your internal table the.

delcare types : this is how you shold do most of the times. to be more professional

types : begin of ty_tab,

field1,

field 2,

end of ty_tab.

data : x_tab type ty_tab.

data: itab like standard table of x_Tab with header line.

or

3) data : begin of itab occurs 0,

field1,

field 2,

end of itab.

with object oriented programming type 3 declartion is ruled out and also with header line specification is not possible in this oops scenerio you have to do like this

data : itab like standard table of vbak.

x_tab like vbak.

Thanks

Mahesh

Former Member
0 Kudos

TYPES: BEGIN of my_type,

field1(1),

field2(1),

END OF my_type.

DATA i_table like standard TABLE OF my_type.

DATA wa_table like my_type.

first declare type and declare internal table with out header line and work area

regards,

srinu reddy.

Former Member
0 Kudos

TYPES : BEGIN OF ty_tab

Fields names

END OF ty_tab.

DATA: itab TYPE STANDARD TABLE OF ty_tab INITIAL SIZE 0. " internal table

DATA: wa TYPE ty_tab. " Work Area

If u want to use Field-symbols, then

FIELD-SYMBOLS : <fs> type ty_tab.

and use like

LOOP AT itab ASSIGNING <fs>.

process <fs>.

ENDLOOP.

Reward if useful

Regards

Prax

Former Member
0 Kudos

E.c.c version . some rules for declaring internal tables.

<b>do not used header line.</b>

compsary used work area.

data: it_db type standard table of kna1,

wa_db type kna1.

types: begin of ty_itab,

fiel1..

2

3

end of ty_itab.

data: it_db type standard table of ty_itab,

wa_db type ty_itab.