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

Simple Difference

Former Member
0 Likes
773

Hi Experts,

Please tell me the difference between. it will be good if you wil explain each of them seperately.

Data: it_kna1 like KNA1.

Data: it_kna1 like KNA1 Occurs 0.

Data: it_kna1 like KNA1 Occurs 0 with Header Line

Data: it_kna1 like line of KNA1.

Data: it_kna1 like standard table of kna1

Data: Begin of it_kna,

kunnr type kna1-kunnr,

End of it_kna1.

I am still confuse where to use these diffrent things.Please tel me where to use each one.

Regards,

Nik

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
743

Data: it_kna1 like KNA1.

A Structure with the KNA1 Structructure properties is defined.

Data: it_kna1 like KNA1 Occurs 0.

An Internal Table is defined with KNA1 Structure without any header line. You will have to define a work area for this table.

Data: it_kna1 like KNA1 Occurs 0 with Header Line

An Internal Table is defined with KNA1 Structure with any header line

Data: it_kna1 like line of KNA1.

A Structure with the record of KNA1 Structructure properties is defined.

Data: it_kna1 like standard table of kna1

Data: Begin of it_kna,

kunnr type kna1-kunnr,

End of it_kna1.

You are defining a internal table structure with only one field KUNNR.

7 REPLIES 7
Read only

Former Member
0 Likes
743

Hi Nikhil,

You can use any of the above for declaring an internal table.

Its only the matter of performance or clarity to be specific.

There is no a thumb rule as when to use a particular declaration.

Regards,

Sandeep

Read only

0 Likes
743

Could you please explain me the diffrence in each of them.

Read only

Former Member
0 Likes
744

Data: it_kna1 like KNA1.

A Structure with the KNA1 Structructure properties is defined.

Data: it_kna1 like KNA1 Occurs 0.

An Internal Table is defined with KNA1 Structure without any header line. You will have to define a work area for this table.

Data: it_kna1 like KNA1 Occurs 0 with Header Line

An Internal Table is defined with KNA1 Structure with any header line

Data: it_kna1 like line of KNA1.

A Structure with the record of KNA1 Structructure properties is defined.

Data: it_kna1 like standard table of kna1

Data: Begin of it_kna,

kunnr type kna1-kunnr,

End of it_kna1.

You are defining a internal table structure with only one field KUNNR.

Read only

0 Likes
743

Hi Sravan,

Could you please explain me when we use structure & when we use internal table.

Regards,

Nik

Read only

0 Likes
743

Hi Nikhil,

Refer standard SAP help to get more idea on internal tables and work area.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb39eb358411d1829f0000e829fbfe/frameset.htm

Regards,

Atish

Read only

0 Likes
743

Difference between Internal Tables and Work Areas

INTERNAL TABLES

- Internal tables are used to obtain data from a fixed structure for

dynamic use in ABAP.

- Each line in the internal table has the same field structure.

- The main use for internal tables is for storing and formatting data from

a database table within a program.

WORK AREAS

- Work areas are single rows of data.

- It should have the same format as any of the internal tables.

- It is used to process the data in an internal table one line at a time.

Internal Tables with Header Line : Here the system automatically creates the work area. The work area has the same data type as internal table. This work area is called the HEADER line. It is here that all the changes or any of the action on the contents of the table are done. As a result of this, records can be directly inserted into the table or accessed from the internal table directly.

Internal Tables without Header Line : Here there is no work area associated with the table. Work area is to be explicitly specified when we need to access such tables. Hence these tables cannot be accessed directly.

HEADER LINE----

CREATED EXPLICITLY------

1.Internal table created by referring to another table

Syntax: Data <f> <type> with header line.

<type> refers to a table data type or table data objects using type or like.

Here internal table <f> is created of the type <type>.

Example:

DATA t_line TYPE line OCCURS 10 with header line.

2. Internal table created by referring to existing structure

Syntax: Data<f> <type> occurs n with header line.

The lines of the internal table <f> have the data type specified in <type> (Can use either like or type).

Example:

DATA flight_tab LIKE sflight OCCURS 10.

CREATED BY DEFAULT---

3. Internal table created With a new structure

Syntax: Data : Begin of <f> occurs <n>,

<component declaration>,

……………………………,

End of <f>.

Work area is created by default.

Example:

Data : Begin of itab occurs 10,

column1 type I,

column2(4) type C,

column3 like mara-ernam,

End of itab.

Read only

0 Likes
743

Thanks Sravan it will be helpful for me.

Regards,

Nik