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: 

How to declare an itab - the 'proper' way???

Former Member
0 Kudos
188

Howdy,

I think there is a newer and better way of declaring internal tables...

currently i use:

*Table for credit notes created

DATA: BEGIN OF output_itab OCCURS 0,

vbeln TYPE vbak-vbeln,

END OF output_itab.

How should this be written????

1 ACCEPTED SOLUTION

Former Member
0 Kudos
84

Here is the standard that I use:

Define my structure in the dictionary - Z_MY_STRUCTURE.

DATA: t_my_table  TYPE STANDARD TABLE OF z_my_structure,
      wa_my_table LIKE LINE OF t_my_table.

Optionally, define a table type in the dictionary that uses your new structure - Z_T_MY_STRUCTURE.

DATA: t_my_table  TYPE z_t_my_structure,
      wa_my_table LIKE LINE OF t_my_table.

I rarely define structures in my program. First of all, I cannot predict how I will need to share the definition, and secondly, we paid big bucks to get a dictionary, so use it.

3 REPLIES 3

Former Member
0 Kudos
84

Not sure what do you mean by proper way, but in <b>ABAP OO context</b>, <b>the way to declare internal tables is without header line</b>.

types: begin of ty_vbeln,
         vbeln type vbak-vbeln,
       end of ty_vbeln.

data: output_itab type table of ty_vbeln. "Internal Table
data: wa_itab type ty_vbeln.              "Workarea

Regards,

Subramanian V.

Peter_Inotai
Active Contributor
0 Kudos
84

Version one, when you define type:

    TYPES: BEGIN OF ty_s_vbeln,
              vbeln TYPE vbak-vbeln,
           END OF ty_s_vbeln.
..
DATA: lwa_vbeln type ty_s_vbeln,
lit_vbeln type table of ty_s_vbeln.

Or you skip the type part..it depends on your needs:

DATA: lwa_vbeln type vbak-vbeln,
lit_vbeln type table of vbak-vbeln.

Peter

Former Member
0 Kudos
85

Here is the standard that I use:

Define my structure in the dictionary - Z_MY_STRUCTURE.

DATA: t_my_table  TYPE STANDARD TABLE OF z_my_structure,
      wa_my_table LIKE LINE OF t_my_table.

Optionally, define a table type in the dictionary that uses your new structure - Z_T_MY_STRUCTURE.

DATA: t_my_table  TYPE z_t_my_structure,
      wa_my_table LIKE LINE OF t_my_table.

I rarely define structures in my program. First of all, I cannot predict how I will need to share the definition, and secondly, we paid big bucks to get a dictionary, so use it.