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

Difference between Line type and Table type

Former Member
10,118

Hi Experts,

I have gone throw the posts related to Line type and Table type , Finally i understood that

If a Line type is created in SE11, and if i want to use it in SE38 , Then it will declared as below

itab type table of zlinetype

wa type line of zlinetype.

If i want to define a internal table in SE38 using Table type only, Then will define as below

types : begin of itab,

            kunnr type kna1-kunnr,

            name1 type kna1-name1,

     end of itab.


Data :  itab_type type table of itab.

            wa_type type itab.


then this type of declaration is called Table type  .

Please clear my doubt. Is this correct ?

1 ACCEPTED SOLUTION
Read only

Former Member
3,587

Hi,

To start with, you can define types globally in the dictionary using SE11 (can be used in all programs), and locally in the program (can only be used inside the program it is created). You use types to create data objects in the program.


The phrase line type is a bit confusing, because its only makes sence in a context of an internal table (or table type), not as a thing on its own.

Here are a few examples which hopefully make things more understandable:

* ------ typing with global types ------

DATA:

* declaration of internal table using global strucutre type

* its line type will be strucure SFLIGHT

   it_sflight TYPE TABLE OF sflight,

" declaration of a work area with structure SFLIGHT

   wa_sflight TYPE sflight,

* declaration of internal table using global table type

* FLIGHTTAB is defined in the dictionary with line type SFLIGHT

   it_sflihgt2 TYPE flighttab,

* declaration of work area using line type of FLIGHTTAB

* with TYPE LINE OF we refer to SFLIGHT

   wa_sflight2 TYPE LINE OF flighttab.

* ------ typing with local types ------

TYPES:

* declaration of a local structure with 4 components

  BEGIN OF ty_sflight_structure,

     carrid TYPE sflight-carrid,

     connid TYPE sflight-connid,

     fldate TYPE sflight-fldate,

     price  TYPE sflight-price,

  END OF ty_sflight_structure,

* declaration of a local table type with line type TY_SLFIGHT_STRUCUTRE

  ty_sflight_table TYPE TABLE OF ty_sflight_structure,

* declaration of a local table type with line type SFLIGHT

  ty_sflight_table2 TYPE TABLE OF sflight.

DATA:

* declaration of table with our local structure

   it_sflight3 TYPE TABLE OF ty_sflight_structure,

* producing the same result with the table type we just defined

   it_sflight4 TYPE ty_sflight_table.

* ------declaration that don't make any sense ------

DATA:

*  syntax error, you can only refer TYPE LINE OF to a table type,

*  and SLFIHGT is a structure!

    wa_sflight5 TYPE LINE OF sflight.



Cheers

5 REPLIES 5
Read only

Former Member
0 Likes
3,587

Hi,

Please refer to the SAP ABAP Help on this subject matter.

In a nutshell, a table type is a TYPE definition.
In your case, it should be

TYPES: itab_type type table of itab.

To declare an internal table:

DATA: myInternalTable type itab_type.

The TYPES definition you used for itab, is a line type: in essence a flat definition of a structure. If you go into the more complex types, you can expand a structure with other table types...

Types cannot hold data!

Best regards,

Zhou

Read only

Former Member
3,588

Hi,

To start with, you can define types globally in the dictionary using SE11 (can be used in all programs), and locally in the program (can only be used inside the program it is created). You use types to create data objects in the program.


The phrase line type is a bit confusing, because its only makes sence in a context of an internal table (or table type), not as a thing on its own.

Here are a few examples which hopefully make things more understandable:

* ------ typing with global types ------

DATA:

* declaration of internal table using global strucutre type

* its line type will be strucure SFLIGHT

   it_sflight TYPE TABLE OF sflight,

" declaration of a work area with structure SFLIGHT

   wa_sflight TYPE sflight,

* declaration of internal table using global table type

* FLIGHTTAB is defined in the dictionary with line type SFLIGHT

   it_sflihgt2 TYPE flighttab,

* declaration of work area using line type of FLIGHTTAB

* with TYPE LINE OF we refer to SFLIGHT

   wa_sflight2 TYPE LINE OF flighttab.

* ------ typing with local types ------

TYPES:

* declaration of a local structure with 4 components

  BEGIN OF ty_sflight_structure,

     carrid TYPE sflight-carrid,

     connid TYPE sflight-connid,

     fldate TYPE sflight-fldate,

     price  TYPE sflight-price,

  END OF ty_sflight_structure,

* declaration of a local table type with line type TY_SLFIGHT_STRUCUTRE

  ty_sflight_table TYPE TABLE OF ty_sflight_structure,

* declaration of a local table type with line type SFLIGHT

  ty_sflight_table2 TYPE TABLE OF sflight.

DATA:

* declaration of table with our local structure

   it_sflight3 TYPE TABLE OF ty_sflight_structure,

* producing the same result with the table type we just defined

   it_sflight4 TYPE ty_sflight_table.

* ------declaration that don't make any sense ------

DATA:

*  syntax error, you can only refer TYPE LINE OF to a table type,

*  and SLFIHGT is a structure!

    wa_sflight5 TYPE LINE OF sflight.



Cheers

Read only

former_member206650
Active Participant
0 Likes
3,587

Hi jitendra,

table types: it can be declared locally as

types : begin of itab,

            kunnr type kna1-kunnr,

            name1 type kna1-name1,

     end of itab.      *this is called structure*


types: tt_itab types table of itab. *tt_itab is the table type*

or by global in se11 in datatypes choose table types and there we define the table type

and the above mentioned structure (itab).

so in short it is mainly used for creating the internal table in se38.

and to define the work area we can use the


wa_itab type itab.


line type: it is one of way to define the table type,in which there will be many fields in simple you are telling the table type should be having the structure as it.


so wat you have done in your example in the query is that you created structure locally and created internal table and work area from it.

hope u got it.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,587

In ddic (SE11) can be defined table types which carry a line type, (data element, table, view, structure or table type)

To use the table/line type in your program you can use :


DATA: itab TYPE tabletype,

      itab2 TYPE TABLE OF linetype,

      record TYPE linetype,

      record2 LIKE LINE OF itab.

In the program (or a TYPE-POOL) you can define a such element with TYPE statement, then use it in the itab definition as with the linetype.


TYPES: BEGIN OF record,

         field1 type ddic1, " ddic ref

         field2 type C length 10, " Abap

       END OF record.

DATA: itab TYPE SORTED TABLE OF record WITH UNIQUE KEY field1,

      warea TYPE record.

Regards,

Raymond

Read only

0 Likes
3,587

Type Lİne of is when you reference the Dıctinary types.

Such as:

Imagine that in se11 there is a table type tt_vbak which is a table type of vbak.

DATA: ls_vbak type line of  tt_vbak

means that it is exactly like

DATA: ls_vbak type vbak.

or can even

Fied:symbols: <lfs_vbak> type line of tt_vbak

as you see it can be used in diffrenet variety