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

Differences

Former Member
0 Likes
598

Hi All,

In following two way of defining the internal table which is the best one and what are the advantages in each one.

TYPES : BEGIN OF LINE,

COLUMN1 TYPE I,

COLUMN2 TYPE I,

COLUMN3 TYPE I,

END OF LINE.

TYPES ITAB TYPE LINE OCCURS 10.

DATA ITAB1 TYPE ITAB.

DATA ITAB2 LIKE ITAB1 .

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
579

Hi Shri Ram,

The statement OCCURS 0 (or 10) has become obsolete. so you should avoid using the same. Also, the internal table with header line should also be avoided. As such OOPs concepts in ABAP doesnt support internal table with header line. The ideal way of declaring an internal table is as follows:

types: begin of ty_itab,

field1,

field2,

end of ty_itab.

Data: itab type table of ty_itab, declares internal table

wa like line of itab ( or wa type ty_itab) . this declares the work area for the internal table itab.

So now you use it in way

loop at itab into wa.

(logic)

endloop .

Hope this helps.

Revert incase of any issues,

Reward points if helpful.

Karan

4 REPLIES 4
Read only

Former Member
0 Likes
579

hi,

internal table without header line is having high performance.

types : begin of ty_mara,

matnr type matnr,

erdat type erdat,

end of ty_mara.

Since we are creating workarea as per client requirement..

Reward with points if helpful.

Read only

Former Member
0 Likes
579

hi,

the best way of defining internal table is

TYPES : BEGIN OF itab,

COLUMN1 TYPE I,

COLUMN2 TYPE I,

COLUMN3 TYPE I,

END OF itab.

*internal table

data : it_itab type standard table of itab.

we can declare work area's where ever needed

regards,

nazeer

Message was edited by:

nazeer shaik

Read only

Former Member
0 Likes
579

hi,

chk this.

*&---------------------------------------------------------------------*
*& Report  ZTYPES                                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT  ZTYPES                                                  .

* Table declaration (old method)
DATA: BEGIN OF tab_ekpo OCCURS 0,             "itab with header line
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
 END OF tab_ekpo.

*Table declaration (new method)     "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
 END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,      "itab
      wa_ekpo TYPE t_ekpo.                    "work area (header line)

* Build internal table and work area from existing internal table
DATA: it_datatab LIKE tab_ekpo OCCURS 0,      "old method
      wa_datatab LIKE LINE OF tab_ekpo.

* Build internal table and work area from existing internal table,
* adding additional fields
TYPES: BEGIN OF t_repdata.
        INCLUDE STRUCTURE tab_ekpo.  "could include EKKO table itself!!
TYPES: bukrs  TYPE ekpo-werks,
       bstyp  TYPE ekpo-bukrs.
TYPES: END OF t_repdata.

DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0,   "itab
      wa_repdata TYPE t_repdata.                 "work area (header line)

Regards

Reshma

Read only

Former Member
0 Likes
580

Hi Shri Ram,

The statement OCCURS 0 (or 10) has become obsolete. so you should avoid using the same. Also, the internal table with header line should also be avoided. As such OOPs concepts in ABAP doesnt support internal table with header line. The ideal way of declaring an internal table is as follows:

types: begin of ty_itab,

field1,

field2,

end of ty_itab.

Data: itab type table of ty_itab, declares internal table

wa like line of itab ( or wa type ty_itab) . this declares the work area for the internal table itab.

So now you use it in way

loop at itab into wa.

(logic)

endloop .

Hope this helps.

Revert incase of any issues,

Reward points if helpful.

Karan