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
920

Hi Friends,

Kindly let me know the difference and the advantages of declaring the internal tables for the following methods.

-


Method : 1

-


TYPES: BEGIN OF I_EKKO,

EBELN LIKE EKKO-EBELN,

AEDAT LIKE EKKO-AEDAT,

BUKRS LIKE EKKO-BUKRS,

BSART LIKE EKKO-BSART,

LIFNR LIKE EKKO-LIFNR,

END OF I_EKKO.

DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,

WA_EKKO TYPE I_EKKO.

-


Method : 2

-


DATA : BEGIN OF IT_EKKO OCCURS 0,

EBELN LIKE EKKO-EBELN,

AEDAT LIKE EKKO-AEDAT,

BUKRS LIKE EKKO-BUKRS,

BSART LIKE EKKO-BSART,

LIFNR LIKE EKKO-LIFNR,

END OF IT_EKKO.

-


TIA.

Regards,

Mark K

1 ACCEPTED SOLUTION
Read only

former_member125931
Active Participant
0 Likes
886

Declaring Types is performance wise good and The new style of definition of internal tables usually doesn't include a header area for the internal table. Furthermore, ABAP Objects will not allow internal tables with header lines. For added performance, instead of declaring a work area--use a field symbol. The work area concept and header line format both require data to be moved from the internal table to the work area or header area. A field symbol is just a pointer that will point to the proper line of the itab. With field symbols, no data needs to be moved. The field symbol just stores the proper memory address to point at the right line. The field symbol can have structure and be made up of fields similar to a work area or header line. Because no data needs to be copied, processing is much faster.

The keys to the usage are:

1) Defining the table records and the field symbol in a similar type.

  • just an ordinary standard table

TYPES: BEGIN OF it_vbak_line,

vbeln LIKE vbak-vbeln,

vkorg LIKE vbak-vkorg,

vtweg LIKE vbak-vtweg,

spart LIKE vbak-spart,

kunnr LIKE vbak-kunnr,

END OF it_vbak_line.

DATA: it_vbak TYPE TABLE OF it_vbak_line.

FIELD-SYMBOLS: <it_vbak_line> TYPE it_vbak_line.

  • or as a screaming fast hash table for keyed reads

TYPES: BEGIN OF it_vbpa_line,

vbeln LIKE vbak-vbeln,

kunnr LIKE vbak-kunnr,

END OF it_vbpa_line.

DATA: it_vbpa TYPE HASHED TABLE OF it_vbpa_line

WITH UNIQUE KEY vbeln.

FIELD-SYMBOLS: <it_vbpa_line> TYPE it_vbpa_line.

2) In ITAB processing, utilize the ASSIGNING command.

  • loop example

LOOP AT it_vbak ASSIGNING <it_vbak_line>.

  • look at records--populate it_zpartner

  • read example

READ TABLE it_vbpa ASSIGNING <it_vbpa_line>

WITH TABLE KEY vbeln = <it_vbak_line>-vbeln.

3) Refer to the field symbol's fields in the loop or after the read.

wa_zpartner-vkorg = <it_vbak_line>-vkorg.

wa_zpartner-vtweg = <it_vbak_line>-vtweg.

wa_zpartner-spart = <it_vbak_line>-spart.

wa_zpartner-kunag = <it_vbak_line>-kunnr.

wa_zpartner-kunwe = <it_vbpa_line>-kunnr.

8 REPLIES 8
Read only

Former Member
0 Likes
886

Hi,

there is no differenence in working.

Regards

Nicole

Read only

Former Member
0 Likes
886

Hi mark,

In the frst example,an internal table without header line is declared while in the second example an internal table with header line is declared.

When an internal table is declared with a header line an aurtomatic work area gets created implicitly.However, if we decalre the internal table without header line then we have to decalare a work area explicitly.

OCCURS 0 - Normally we declare with header line internal table with ocurs 0 specification. if we declare internal table with

occurs 0 then it will initially get 8 kilo bytes memory

Note:- Though an implicit work area gets created in case of internal table with header line but still it is recommended that we should create internal table without header line as it is convenient to use & accessing data is simple.

Also check,

http://sap.mis.cmich.edu/sap-abap/abap04/sld012.htm

Best of luck.

Bhumika

Read only

Former Member
0 Likes
886

As per my understanding there is no difference but basis ver. 6.10 onwards 'occurs 0' addition is obsolete..so u should avoid method 2 for declaring internal tables.

Regards,

Joy.

Read only

former_member386202
Active Contributor
0 Likes
886

Hi,

The internal table declared in method 1 is without header line n second one is with header line which is now obsolet in ECC.

Regards,

Prashant

Read only

former_member125931
Active Participant
0 Likes
887

Declaring Types is performance wise good and The new style of definition of internal tables usually doesn't include a header area for the internal table. Furthermore, ABAP Objects will not allow internal tables with header lines. For added performance, instead of declaring a work area--use a field symbol. The work area concept and header line format both require data to be moved from the internal table to the work area or header area. A field symbol is just a pointer that will point to the proper line of the itab. With field symbols, no data needs to be moved. The field symbol just stores the proper memory address to point at the right line. The field symbol can have structure and be made up of fields similar to a work area or header line. Because no data needs to be copied, processing is much faster.

The keys to the usage are:

1) Defining the table records and the field symbol in a similar type.

  • just an ordinary standard table

TYPES: BEGIN OF it_vbak_line,

vbeln LIKE vbak-vbeln,

vkorg LIKE vbak-vkorg,

vtweg LIKE vbak-vtweg,

spart LIKE vbak-spart,

kunnr LIKE vbak-kunnr,

END OF it_vbak_line.

DATA: it_vbak TYPE TABLE OF it_vbak_line.

FIELD-SYMBOLS: <it_vbak_line> TYPE it_vbak_line.

  • or as a screaming fast hash table for keyed reads

TYPES: BEGIN OF it_vbpa_line,

vbeln LIKE vbak-vbeln,

kunnr LIKE vbak-kunnr,

END OF it_vbpa_line.

DATA: it_vbpa TYPE HASHED TABLE OF it_vbpa_line

WITH UNIQUE KEY vbeln.

FIELD-SYMBOLS: <it_vbpa_line> TYPE it_vbpa_line.

2) In ITAB processing, utilize the ASSIGNING command.

  • loop example

LOOP AT it_vbak ASSIGNING <it_vbak_line>.

  • look at records--populate it_zpartner

  • read example

READ TABLE it_vbpa ASSIGNING <it_vbpa_line>

WITH TABLE KEY vbeln = <it_vbak_line>-vbeln.

3) Refer to the field symbol's fields in the loop or after the read.

wa_zpartner-vkorg = <it_vbak_line>-vkorg.

wa_zpartner-vtweg = <it_vbak_line>-vtweg.

wa_zpartner-spart = <it_vbak_line>-spart.

wa_zpartner-kunag = <it_vbak_line>-kunnr.

wa_zpartner-kunwe = <it_vbpa_line>-kunnr.

Read only

Former Member
0 Likes
886

You can define internal tables either with (WITH HEADER LINE addition) or without header lines.

An internal table with header line consists of a work area (header line) and the actual table body. You address both objects

using the same name. The way in which the system interprets the name depends on the context. For example, the MOVE statement applies to the header line, but the SEARCH statement applies to the body of the table.

To avoid confusion, you are recommended to use internal tables without header lines. This is particularly important when you use nested tables. However, internal tables with header line do offer a shorter syntax in several statements

( APPEND, INSERT, MODIFY, COLLECT, DELETE, READ, LOOP ).

Within ABAP Objects, you can only use internal tables without a header line. You can always address the body of an internal table <itab> explicitly by using the following syntax: <itab>[]. This syntax is always valid, whether the internal table has a header line or not.

Read only

Former Member
0 Likes
886

Hi,

Both the method works in the same manner. But the first method is performance wise good.

Sharin

Read only

Former Member
0 Likes
886

Hi,

The both declarations are same.

In the first case ,the internal table is without header line, while in the second case the internal table is with header line.

An internal table with headerline will have a workarea, but the internal table without headerline will not have, in this ace we need to explicitly create a workarea.

But the declaration with OCCURS 0 is Obsolete now , so need not use that instead we use internal table without headerline.

Even within ABAP Objects, you can only use internal tables without a header line. You can always address the body of an internal table <itab> explicitly by using the following syntax: <itab>[]. This syntax is always valid, whether the internal table has a header line or not.

hope this helps,

plz reward if useful.

thanks,

dhanashri.

Edited by: Dhanashri Pawar on Jul 22, 2008 7:46 AM

Edited by: Dhanashri Pawar on Jul 22, 2008 7:47 AM