Skip to Content
avatar image
Former Member

difference between with and without header line of internal table

Hi all,

can you explain

1) The difference between

whih header line and with out heater line of internal table.

ex:-

a) Data : itab like mara occurs 0 with header line.

b) Data: itab like mara occurs 0.

2)work area / field string and internal table

which one is prefarable for good performance any why ?

Please give the detailed explanation with example code.

Thanks in advance

Ravi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 08, 2006 at 10:01 AM

    Hi,

    When you create internal table with headerline an explicit workarea is attached with the table.

    Whenever you loop at table or read a table the value read from the table is stored in the header of the table.

    Syntax

    loop at internal_table

    &

    Read table internal_table.

    You can use name of the table directly to access the value

    where as when create internal table without header you have to create a structure ( Workarea ) for the internal table.

    when you read or loop have get stored into structure you specify

    Syntax will be

    loop at internal_table into structure

    &

    Reab table internal_table into structure

    and you have to read the value from the structure

    Structure (Workarea) type should of internal table type

    otherwise error.

    As per my knowledge explicit defination of workarea is better than declaring internal_table with header line.

    Since in our project it standard to use explicit workarea other than internal table with headerline.

    Fell free to ask any futher question.

    Reward some points if it helps you

    Regards,

    Manoj B Gupta

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 08, 2006 at 10:09 AM

    Hi Ravi,

    Header line can be used as a work area while processing internal table. You need not have to create an extra work-area for the int.table.

    If you create an internal table with header line, data is sent to header line and when you use APPEND statement , it is sent from Header line to the internal table.

    eg: Syntax for int.table with header line is

    DATA: ITAB TYPE MARA OCCURS 0 WITH HEADER LINE

    Usually what u do with structure is

    Data: struct type mara.

    struct-matnr = somevalue.

    struct-mbrsh = somevalue.

    append struct into itab.

    You can avoid those statements by directly writing

    itab-matnr = somevalue.

    append itab.

    Initialising Internal tables

    1) CLEAR <ITAB>.

    If u use itab as one with header line, this stmt clears contents of header line only.

    2) CLEAR <ITAB>[].

    This clears the body contents of int.table.

    So in order to access an internal table with header line, we have to call it as ITAB[] or else only the header line is called.

    Also header line eliminates the use of extra structure.

    For learning more about Internal table operations with Header line, check this link,

    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb36a1358411d1829f0000e829fbfe/content.htm

    Regards,

    SP.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 08, 2006 at 03:40 PM

    Hi Ravi,

    have a look at the following link.

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

    hope it ll help you.

    regards,

    Kinshuk

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 08, 2006 at 05:11 PM

    HI Ravi,

    1) The difference between

    whih header line and with out heater line of internal table.

    ex:-

    a) Data : itab like mara occurs 0 with header line.

    b) Data: itab like mara occurs 0.

    -While adding or retrieving records to / from internal table we have to keep the record temporarily.

    -The area where this record is kept is called as work area for the internal table.

    -The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.

    <b>-Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.</b>

    a) Data : itab like mara occurs 0 with header line.

    <b> table is with header line</b>

    b) Data: itab like mara occurs 0.

    <b> table is without header line</b>

    2)work area / field string and internal table

    which one is prefarable for good performance any why ?

    -The header line is a <b>field string</b> with the same structure as a row of the body, but it can only hold a single row , whereas <b>internal table</b> can have more than one record.

    In short u can define a <b>workarea</b> of an internal table which means that area must have the same structure as that of internal table and can have one record only.

    Example code:

    data: begin of itab occurs 10,

    ab type c,

    cd type i,

    end of itab. " this table will have the header line.

    data: wa_itab like itab. " explicit work area for itab

    data: itab1 like itab occurs 10. " table is without header line.

    Hope this will clear your doubts, if ur satisfied then do close this thread by rewrding appropriate points to the helpful answers.

    Cheers

    Sunny

    reward points ,if found helpful

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      HI Ravi,

      Sorry for the delay as i was not online on SDN,

      Well to make it simpler.

      Say we have an internal table with an header line which mean nothing that it has got a workarea defined to it.

      Eg:

      - Data : itab like mara occurs 0 with header line

      - data: begin of itab occurs 10,

      ab type c,

      cd type i,

      end of itab. " this table will have the header line.

      <b>Otherwise</b> u need to define the define a <b>explicit workarea for the same</b> like. <b></b>

      - data: wa_itab like itab. " explicit work area for itab

      <b>Another way to define the same</b>.

      data: itab1 like itab occurs 10. " table is without header line.

      data: itab1 like itab occurs 10 with header line. " table is with header line.

      Hope you will be clear , if not do let me know.

      If ur satisfied then do close this thread by rewrding appropriate points to the helpful answers.

      Cheers

      Sunny

      reward points ,if found helpful

      Message was edited by: Sunny