Reg.  comparison of two types of Internal tables.

Hi friends!
    I have a doubt while declaring a internal table. whether to declare with header line or without header line. Can all types of manipulations be done after retrieving data from DB table to the Inernal table with headerline. Which of these two is more efficient. I would like to know the clear comparison between these two types.
regards,
prasad

Hi,
Incase of declaring an Internal table with header line will make the processing looks simple as with in a loop and endloop statement your internal manipulations namely AT NEW, AT LAST, COLLECT and other similar statements will work out, but still clearing of the respective header needs to be done whenever there is exit happens to the application after successful completion. As because I have encountered errors due to failure in clearing header as in case of batch applications and BDC applications. Also as mentioned memory  management also needs to be considered.
Incase of declaring with work area except for the internal manipulations being pointed above, for all other cases it works out effectively and also more safer way to code your application.
Also the declaration with or without header line also accounts whenever there is a call to a function module at which if we require to receive or pass some data through TABLES option then we need to look for the specified table type being used.
So in all it depends the process in your application where in the type of declaration accounts.
Regards,
Jagath.

Similar Messages

  • Types of internal tables with regard to EFFICIENCY

    Will any one tell me syntax to define each type of internal table  (standard, sorted , hashed , database) . how to compare their efficincy ( access time which is more effficent) is there any documantation or programme of such type exist then please tell  . i want to declare each type of above table and also to compare them w.r.t to efficeny thanks  want urgent reply

    Hi,
    There are 3 types of Internal tables.
    Standard Internal Tables:
    Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
    This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to the number of table entries.
    Sorted Internal Tables:
    Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
    This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
    Hashed Internal Tables:
    Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
    This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
    using internal tables that are similar to database tables.
    http://help.sap.com/saphelp_470/helpdata/EN/fc/eb35de358411d1829f0000e829fbfe/frameset.htm
    Regards,
    Kiran Sure

  • Difference between line type and internal table?

    Hi..
    I wanted to know, what is the difference between Line type and Internal Table?

    Hi,
        Before the 4.7 release in SAP if we want to define an internal table we have to write the defination using the occurs statement and we need to define all the fields using INCLUDE STRUCTURE or indidually all the fields ine by one.
    From 4.7 release of R/3 SAP introduced the Line type concept and it's part of the ABAP OOPS concept. for internal table defination we don't need to use the occur statements. Instead INCLUDE structure  we need to create a Line type for that structure in Se11 and then we can define the internal table like :
    DATA : ITAB TYPE TABLE OF <LINE_TYPE>.
    Only thing is this table will be  a table without header. So for internal table processing we need to define a work area structure of type line of line type  . EX:
    DATA: WA_ITAB TYPE LINE OF <LINE_TYPE>.
    Hope this helps.
    Thanks,
    Greetson

  • Hi I want to know the difference between the type of internal tables.

    I know the types of internal table but i dont know the difference between them can any one explain me in simple sentence.

    Hi,
    <b>Standard Internal Tables</b>
    Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
    This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to
    the number of table entries.
    <b>Sorted Internal Tables</b>
    Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
    This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of
    table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
    <b>Hashed Internal Tables</b>
    Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
    This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
    using internal tables that are similar to database tables.

  • What is the maximal line length of type any internal table

    Dear all,
    who can tell me what is the maximal line length of type any internal table.
    Thanks!

    There is no limit to the record length of an internal table.
    There is overall memory limit for every program (as setup by your basis). So, depending on the width of the ITAB, the number of records in ITAB is limited by the assigned memory.

  • Diference between DATA: and TYPES: on internal tables

    Hi people,
    Can somebody help me. I wanna know whats the diference between DATA: and TYPES: on internal tables
    and whitch has the best performance, here is a eg:
    DATA: BEGIN OF ti_sbook occurs 0,
              carrid   LIKE sbook-carrid,
              fldate   LIKE sbook-fldate,
              customid LIKE sbook-customid,
              loccuram LIKE sbook-loccuram,
           END OF ti_sbook.
    AND
    TYPES: BEGIN OF ti_sbook ,
              carrid   LIKE sbook-carrid,
              fldate   LIKE sbook-fldate,
              customid LIKE sbook-customid,
              loccuram LIKE sbook-loccuram,
           END OF ti_sbook.
    DATA: gw_sbook       TYPE  TABLE OF ti_sbook,
    gs_sbook       TYPE ti_sbook.
    witch of both types is better?
    thanks.

    Hi Marcelo,
    For compatibility matters is better to create internal tables with a work area separately. So yes it's better to use types. When you work with Object Oriented coding you will need to use internal tables defined with types. Also when defining tables with types is the new way of coding, the another coding is getting obsolete defined by SAP. That's why when working in ABAP with OO (Object Oriented) code you'll have to define tables with types and not the other way.
    Hope it helps.
    Regards,
    Gilberto Li

  • One Example program required on All types of internal tables

    Hi All
    Good Morning and Good day to you. I know that there are three types of internal tables like standard, sorted and hashed. I would request you to please send me one small example program on each type, so that i can understand better about the usage of different types.
    Hoping for positive reply.
    Thanks in advance.
    Regards
    Nagaraju

    hi,
    data: begin of struct,
          v_id type i,
          v_name(10) type c,
          v_phn type i,
          end of struct.
                                 "STANDARD TABLE.
    data itab like standard table of struct with default key .
           write 'standard table'.
           struct-v_id = 1.
           struct-v_name = 'subash'.
           struct-v_phn = 234567.
           "INSERT struct into  ITAB.
           append struct to itab.
           struct-v_id = 3.
           struct-v_name = 'sanchana'.
           struct-v_phn = 2378499.
           INSERT struct into  ITAB index 1.
           "append struct to itab.
           struct-v_id = 2.
           struct-v_name = 'sanchith'.
           struct-v_phn = 2455667.
           INSERT struct into  ITAB index 2 .
           loop at itab into struct.
           write: / struct-v_id , struct-v_name,struct-v_phn.
           endloop.
           skip.
           uline.
                               "sorted table.
    data itab1 like sorted table of struct with non-unique key v_id.
           write 'sorted table'.
           struct-v_id = 3.
           struct-v_name = 'subash'.
           struct-v_phn = 234567.
           INSERT struct into TABLE ITAB1.
           "append struct to itab.
           struct-v_id = 2.
           struct-v_name = 'sanchana'.
           struct-v_phn = 2378499.
           INSERT struct into table ITAB1.
           "append struct to itab.
           struct-v_id = 1.
           struct-v_name = 'sanchith'.
           struct-v_phn = 2455667.
           INSERT struct into  ITAB1 index 1.
           "append struct to itab.
           loop at itab1 into struct.
           write: / struct-v_id , struct-v_name, struct-v_phn.
           endloop.
           skip.
           uline.
                            "hashed table
       data itab2 like hashed table of struct with unique key v_id.
           write 'hashed table'.
           struct-v_id = 1.
           struct-v_name = 'subash'.
           struct-v_phn = 234567.
           INSERT struct into TABLE ITAB2.
           struct-v_id = 3.
           struct-v_name = 'sanchana'.
           struct-v_phn = 2378499.
           INSERT struct into TABLE ITAB2.
           struct-v_id = 2.
           struct-v_name = 'sanchith'.
           struct-v_phn = 2455667.
        INSERT struct into TABLE ITAB2.
    &--SORTED USING SORT STATEMENT--
           loop at itab2 into struct.
           write:'non-sorted table' , / struct-v_id , struct-v_name, struct-v_phn.
           endloop.
           sort itab2 by v_id.
      SKIP.
            loop at itab2 into struct.
           write: 'sorted hash table',  / struct-v_id , struct-v_name, struct-v_phn.
           endloop.
           SKIP.
           ULINE.
    <b>Reward Useful Points</b>
    Siva

  • How meny types of internal tables?

    how meny types of internal tables? can any one explain brifly what r their use?

    INTERNAL TABLES:
    Internal tables are holds the data which is having the same structure and storing it in working memory in ABAP. The data is stored line by line in the memory. The main purpose of internal table is for storing and formatting data from a database table within a program. It is used to minimize the DB access time in report programs.
    Internal table are dynamic data objects, since they can contain any number of lines of a particular type. The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes.
    Types of Internal Tables :
    1. Standard Internal Tables :
    Standard tables have an internal linear index. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries. WE can fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command).
    2. Sorted tables :
    Sorted tables are always saved sorted by the key. They also have an internal index. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional to the number of table entries, since the system uses a binary search. Entries are inserted according to the sort sequence defined through the table key.
    3. Hashed tables :
    Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of table entries, and is constant, since the system access the table entries using a hash algorithm. we cannot access a hashed table using its index.

  • Types of internal tables - More explanation(urgent)

    hi friends,
                I wanted to explore diiferent types of internal table. when i went through the SAP.Help.Com for this , i wasnot able to get a clear idea of those 4 types of tables
    Mainly i wanted to know
    what is 1.standard table
            2.Hashed Table
            3.Sorted Table
            4. Index tables..
    what are the advantages of these table and please explain me a scenario for when under what circumstances we would use these?
    please reply me soon as i need to submit my documents reagarding this.
    Thanks in advance
    Thanks&Regards
    Prasanna.

    Standard tables
    This is the most appropriate type if you are going to address the individual table entries using the index. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard table increases in a linear relationship with the number of table entries. If you need key access, standard tables are particularly useful if you can fill and process the table in separate steps. For example, you could fill the table by appending entries, and then sort it. If you use the binary search option with key access, the response time is logarithmically proportional to the number of table entries.
    Sorted tables
    This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
    Hashed tables
    This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data.

  • Reg  comparison of two  internal tables

    hi friends,
    please help me solving this.
    there are two internal tables t_zvs38 and t_value
    1.t_value like seahlpres
    2.t_zvs38 like zvs38.
    values in t_value will be like this.
    first line wil contain zmdtype(mandatory document) and second line will contain
    zmdtypet (the description for zmdtype).
    eg.
    D001 -
    -zmdtype
    internal----
    zmdtypet
    D002
    external
    D003
    renewal
    values in t_zvs38.
    for a particular sales.org the zmdtype is filled.
    select vkorg zmdtype into corrsponding fields of table t_zvs38
    where vkorg = p_vkorg.
    Now i want to compare t_value and t_zvs38 with field zmdtype
    and delete the contents of  t_value which are not in t_zvs38.
    i have written like this.
    loop at t_value.
    read table t_zvs38 with key zmdtype = t_value-string.
    if sy-subrc ne 0.
    delete t_value. "to delete zmdtype
    sy-tabix = sy-tabix + 1.
      delete t_value. " to delete zmdtypet
    else.
    sy-tabix = sy-tabix +2. "to go to next zmdtype.
    endif.
    endloop.
    but it is deleting all the contents of t_value.
    points are assured.

    CLEAR zvs32t.
      SELECT zvs32tzmdtype zvs32tzmdtypet
        INTO (zvs32t-zmdtype, zvs32t-zmdtypet)
        FROM zvs32t
        JOIN zvs32
        ON   zvs32tzmdtype = zvs32zmdtype
        WHERE zvs32t~spras    = sy-langu
        AND   zvs32~zfrenewal = space.
         WRITE zvs32t-zmdtype TO t_value.
        APPEND t_value.
        WRITE zvs32t-zmdtypet TO t_value.
        APPEND t_value.
      ENDSELECT.
      SELECT vkorg vkbur zmdtype FROM zvs38 INTO CORRESPONDING FIELDS OF TABLE t_zvs38
      WHERE vkorg = p_vkorg
    AND vkbur = p_vkbur.
      LOOP AT t_value INTO wa_area1.
        v_index = sy-tabix.
        READ TABLE t_zvs38 INTO wa_area2 WITH KEY zmdtype = wa_area1-string
      BINARY SEARCH.
       IF sy-subrc NE 0.
          IF l_flag IS INITIAL.
            DELETE t_value INDEX v_index.
           ELSE.
            CLEAR l_flag.
          ENDIF.
       ELSE.
          l_flag = 'X'.
       ENDIF.
      ENDLOOP.
    Using this code ,i am unable to ge the correct output.Thank u all for ur help.

  • Grouping of two rows of internal table

    Hi all,
    I am having a requirement in which I want to group two rows of an internal table and assign a pointer to the two rows.
    This pointer variable will then be passed to ALV.
    Help reqd.
    regards.

    Hi Gaurav,
    Hope the below code helps:
    TYPES :BEGIN OF TY_ITAB2,
    DATA(400),
    END OF TY_ITAB2.
    DATA: ITAB3 TYPE TY_ITAB2 OCCURS 0 WITH HEADER LINE
    Loop at itab1.
    ITAB3-DATA = ITAB1-LABEL.
    APPEND ITAB3.
    ITAB3-DATA = ITAB1-MATNR.
    APPEND ITAB3.
    endloop.
                        or
    You can create a deep internal table. You can declare one Column as an internal table and store the NOTES in that Internal table for each row.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
    you can check the example in the link
    Kindly Reward Points If You Find The Reply Helpful.
    Cheers,
    Chaitanya.

  • Data types in internal tables.

    Examples for LINE & KEY.

    Mithun,
    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.
    Pls. reward if useful

  • Assigning value to Field - Symbol ( which is type of internal table field )

    Hi All,
      I am facing problem to assign the value to a field symbol. My requirement is creating a dynamic internal table and populate values into that internal table, so that i can display the values .
      I am having a structure with fields like status , Plant1 name , Plant2 name.....Plant n .
      So i declared an internal table it_tab with this structure.
      I am having one more table which having number of records for Plant1 ,Plant 2 ,....Plant n based on some condition.
      I need to count the number of records for Plant1 and i need to put in the internal table it_tab.
      For this i created field-symbol .
    Here, t_deployment table will have the plants 1,2,3...and
         t_devobject will have some records for these plants.
    LOOP AT T_DEPLOYMENT. 
    clear w_count.
    LOOP AT T_DEVOBJECT WHERE ZDEPLOYMENT = T_DEPLOYMENT-DOMVALUE_L AND
                              ZADSTATUS = '10'.
    w_count = w_count + 1.
    ENDLOOP.
    concatenate 'it_tab-' t_deployment-domvalue_l into var_bet_name.
    assign var_bet_name to <bet_var_name>.
    now my internal table field i.e. it_tab-plant1 came into <bet_var_name> . But i want to assign a value for it.
    at last what i need is it_tab-plant1 = w_count.
    whaterver the w_count has value that needs to assign to it_tab-plant1. But i don't want to assign directly it it_tab-plant1. I want to assign dynamically. Because tommorrow some more plants added to t_deployments , i don't want to make changes to my program. It should take care....w/o changing the program.
    I tried the following statement.
    (<bet_var_name>) = w_count. But its not working.
    Please let me know how i can get this.
    Thanks in Advance.
    Pavan.

    Hi pavan,
    As ur requirement is creating a dynamic internal table,
    try the following way,
    remember the fieldcat should be of type LVC not SLIS.
    BUILD LT_LVCFIELDCAT in a way that, the value from the internal table becomes the fieldname
    ex:-
    loop at it_models INTO WA_MODELS.
        LS_LVCFIELDCAT-FIELDNAME = WA_models-MODEL.
        LS_LVCFIELDCAT-SELTEXT = WA_models-MODEL.
    append ls_lvcfieldcat to lt_lvcfieldcat.
    endloop.
    DATA: DREF TYPE REF TO DATA,WA_REF TYPE REF TO DATA.
    FIELD-SYMBOLS: <TEMP_TAB> TYPE TABLE, <TEMP_WA> TYPE ANY.
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_LVCFIELDCAT
        IMPORTING
          EP_TABLE        = DREF.
      ASSIGN dref->*  TO <TEMP_TAB>.
    now basing on the fieldcatalog <temp_tab> is build.
    NOW FILL <TEMP_TAB>.
    WHILE FILLING, ASSIGN COMPONENT IDX/NAME.....
    this statement will be very usefull.
    i hope this will be help full.
    pls reward the points if it helps u.
    regards
    Hyma

  • What type of internal table should I use based from my scenario...

    Hello Experts,
    I am currently having a dillema here because I am trying to optimize a certain
    part of a report where in the internal table contains around 300,000 lines of
    records. The original internal table is of type standard table. So what the original
    programmer did was to delete certain records in a given condition then sort it
    by fields 1 and 2 in ascending order. Now, it then loops through that internal table
    but gives run time error because it exceeded the limit in our prod server which is only 10 mins.
    Now what I did was to try modifying the internal table to make it of type sorted. This is to eliminate
    the sort statement. I dont know if what I am doing is right. Help would be greatly appreciated and
    rewarded. Thanks a lot guys and take care!

    Hi,
    types: begin of t_itab,
             field1  like pa0001-pernr,
             field2  like pa0001-ename,
           end   of t_itab.
    data: ls_itab  type t_itab,
          lt_itab  type  hashed table of t_itab  with unique key field1 field2.
      select pernr ename into table lt_itab  from pa0001.
      loop at lt_itab.
        <<<<< your logic
      endloop.
    aRs

  • Table types and internal table

    Hi all,
    What is the relationship between table type in ABAP dictionary and internal table?
    Moderator message : Search for available information OR read ABAP documentation. Thread locked.
    Edited by: Vinod Kumar on Jul 16, 2011 11:16 AM

    You can INCLUDE TYPE.
    Types: begin of itab,
           field1 type string,
           field2 type string,
    *      More Fields in here.
           Field30 type string,
           End of itab.
    Data: lt_itab type table of itab.
    TYPES BEGIN OF new_itab.
           INCLUDE type itab.
    TYPES: field31 type string,
           field32 type string,
    END OF new_itab.
    Regards,
    Rich Heilman

Maybe you are looking for