1

And which one should be preferred / why?

So I have a TYPE defined locally:

TYPES:
    BEGIN OF CUSTOMER_STRU_TYPE,
        KUNNR TYPE KNA1-KUNNR,
        NAME1 TYPE KNA1-NAME1,
    END OF CUSTOMER_STRU_TYPE.

and I think these 2 statements seen below will both do the same thing:

DATA:
    CUSTOMER_TAB TYPE CUSTOMER_STRU_TYPE OCCURS 5.

DATA:
    CUSTOMER_TAB TYPE STANDARD TABLE OF CUSTOMER_STRU_TYPE.

Are there any differences between the 2 statements seen above and which one should be preferred?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
  • You have already asked about it. The first statement with `OCCURS` defines an internal table with header line, the other defines an internal table without header line. `OCCURS 5` means that initially there will be assigned memory for 5 rows. – Jagger Apr 07 '16 at 06:50
  • 2
    Possible duplicate of [What is WITH HEADER LINE used for in ABAP?](http://stackoverflow.com/questions/36282951/what-is-with-header-line-used-for-in-abap) – Jagger Apr 07 '16 at 06:50
  • Hi @Jagger . The difference between those 2 are: the existing / lack of: STANDARD TABLE OF not "WITH HEADER LINE".. This is a different question actually. – Koray Tugay Apr 07 '16 at 06:56
  • With all due respect I disagree. :) Especially that I mentioned about `STANDARD TABLE OF WITH HEADER LINE` in one of the comments there. – Jagger Apr 07 '16 at 06:57
  • @Jagger Well ok, you are probably right. I am very new to SAP / ABAP so I am still trying to understand. I think it will make sense with time, I am just confused at the moment. Thank you for your help. – Koray Tugay Apr 07 '16 at 06:59

1 Answers1

3

The main difference between the two statements is that, in the first one you're reserving memory space for storing 5 lines of customer_tab table. In terms of performance, the best statement is the second one.

David
  • 86
  • 7
  • The first statement also declares a "header line" in addition to the table, thus when you try to access the table you have to explicitly state that you want the table using square brackets ( eg. CUSTOMER_STRU_TYPE[] ). – Esti Apr 19 '16 at 02:44