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 tables using types.

Former Member
0 Kudos

wat is difference b/w internals tables using TYPES and DATA:ITAB LIKE KNA1...

which one is better one based on performance.

vijay

6 REPLIES 6

Former Member
0 Kudos

Hi,

If you declare an internal table using TYPES...Then you cannot populate the internal table..

This is like the table types that you create in SE11..

Where as if you declare using DATA..you can populate the internal table..

Thanks,

Naren

Former Member
0 Kudos

Check this thread:

Regards,

Rohit

Reward the helpful replies

Former Member
0 Kudos

Hi,

If you are mentioning about LIKE TABLE OF and TYPE TABLE OF...Then there is no difference...I believe performance will be the same for both of them..

Thanks,

Naren

Former Member
0 Kudos

Hi Vijay,

Check this info.

<b>Internal tables</b>

Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.

Like all elements in the ABAP type concept, internal tables can exist both as data types and as data objects A data type is the abstract description of an internal table, either in a program or centrally in the ABAP Dictionary, that you use to create a concrete data object. The data type is also an attribute of an existing data object.

Internal Tables as Data Types

Internal tables and structures are the two structured data types in ABAP. The data type of an internal table is fully specified by its line type, key, and table type.

Line type

The line type of an internal table can be any data type. The data type of an internal table is normally a structure. Each component of the structure is a column in the internal table. However, the line type may also be elementary or another internal table.

Key

The key identifies table rows. There are two kinds of key for internal tables - the standard key and a user-defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method.

If a table has a structured line type, its default key consists of all of its non-numerical columns that are not references or themselves internal tables. If a table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty.

The user-defined key can contain any columns of the internal table that are not references or themselves internal tables. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key.

Hope this resolves your query.

<b>Reward all the helpful answers.</b>

Regards

Former Member
0 Kudos

Hi Vijay Reddy,

If u use the types is nothing but the structure.

If u want to create the internal table then we can use the syntax.

Plz go through this program and check the performance. If u use the types performance is better.

REPORT ZFORALLENTRIES .

TABLES : LFA1.

*PARAMETERS : VEN LIKE LFA1-LIFNR.

SELECT-OPTIONS : VENDOR FOR LFA1-LIFNR.

TYPES : BEGIN OF TY_VEN,

LIFNR LIKE LFA1-LIFNR,

NAME1 TYPE LFA1-NAME1,

  • EBELN LIKE EKKO-EBELN,

  • AEDAT LIKE EKKO-AEDAT,

  • EBELP TYPE EKPO-EBELP,

  • MATNR LIKE MARA-MATNR,

END OF TY_VEN.

BEGIN OF TY_PORD,

EBELN LIKE EKKO-EBELN,

AEDAT LIKE EKKO-AEDAT,

EBELP TYPE EKPO-EBELP,

MATNR LIKE MARA-MATNR,

END OF TY_PORD.

  • BEGIN OF TY_MAT,

  • MATNR LIKE MARA-MATNR,

  • ERNAM TYPE MARA-ERNAM,

  • END OF TY_MAT,

  • BEGIN OF TY_PITEM,

  • EBELP TYPE EKPO-EBELP,

  • END OF TY_PITEM.

DATA : IT_TOTAL TYPE STANDARD TABLE OF TY_VEN WITH HEADER LINE.

  • IT_PORD TYPE STANDARD TABLE OF TY_PORD WITH HEADER LINE.

  • IT_MAT TYPE STANDARD TABLE OF TY_MAT WITH HEADER LINE,

  • IT_PITEM TYPE STANDARD TABLE OF TY_PITEM WITH HEADER LINE.

*SELECT LIFNR NAME1 FROM LFA1 INTO TABLE IT_TOTAL WHERE KUNNR IN S_KUNNR.

*IF NOT IT_total[] IS INITIAL.

  • SELECT ebeln aedat ebelp matnr FROM KNB1 INTO TABLE IT_COMP FOR ALL

*ENTRIES IN

  • IT_CUST WHERE KUNNR = IT_CUST-KUNNR.

*ENDIF.

*LOOP AT IT_CUST.

  • WRITE: / IT_CUST-KUNNR, IT_CUST-KUNNR.

  • READ TABLE IT_COMP WITH KEY KUNNR = IT_CUST-KUNNR BINARY SEARCH.

  • IF SY-SUBRC = 0.

*

  • WRITE :IT_COMP-BUKRS.

  • ENDIF.

SELECT ALIFNR ANAME1 BEBELN BAEDAT CEBELP DMATNR

INTO TABLE IT_TOTAL FROM

LFA1 AS A INNER JOIN EKKO AS B ON ALIFNR = BLIFNR

INNER JOIN EKPO AS C ON BEBELN = CEBELN

INNER JOIN MARA AS D ON CMATNR = DMATNR .

  • WHERE LFA1-LIFNR IN VENDOR.

LOOP AT IT_TOTAL.

WRITE : / IT_TOTAL-LIFNR , IT_TOTAL-NAME1 , IT_TOTAL-EBELN,

IT_TOTAL-AEDAT , IT_TOTAL-EBELP , IT_TOTAL-MATNR.

ENDLOOP.

*******Rewords some points.

Rgds,

P.Naganjana Reddy

Former Member
0 Kudos

Internal tables we can declare diffrent types.

Example 1.

data : begin of i_mara occurs 0,

matnr like mara-matnr,

end of i_mara.

if you see above internal table declaration,it has both header and Body.

if internal table has both header and body,then it is performance issue.

Example 2.

<b>Structure</b>

types : begin of ty_mara,

matnr type mara-matnr,

end of ty_mara.

<b>Internal table</b>

data i_mara type standard table of ty_mara.

<b>Work Area</b>

data wa_mara like line of i_mara.

if you use above internal table ,it has only body,we do not have header,

so we will have good performance.

if useful,mention reward points

Thanks

Seshu