I have been studying this book and quoting from it:
DATA: BEGIN OF CUSTOMER_TAB OCCURS 5,
KUNNR TYPE KNA1-KUNNR,
NAME1 TYPE KNA1-NAME1,
END OF CUSTOMER_TAB.
This declaration creates an internal table and a structure using the same name: CUSTOMER_TAB.
And then in the following pages:
Declaring Both an Internal Table and a Structure by Referring to a Structured
Local/Global TYPE or Local/Global Structure
DATA <internal table name> {TYPE|LIKE} <structure name> OCCURS <number> WITH HEADER LINE.
WITH HEADER LINE is a reserved key phrase. The addition of this phrase creates a structure.
I am confused at this moment. Is the first example declaring only an Internal Table or an Internal Table and a Structure with the same name?
The question should be "What was WITH HEADER LINE used for in ABAP". You should see them only in legacy code. They are allowed only outside classes and are obsolete anyway.
Answering your question. It is both. It declares an internal table customer_tab[] and a structure customer_tab.
You could then do such "amazing" things like.
LOOP AT customer_tab. "loops at tab CUSTOMER_TAB and stores current record in header line structure CUSTOMER_TAB. :]
"do something with header line
END LOOP.
or
APPEND customer_tab.
As you see it is shorter and quite appealing to be used for its brevity. Though it is hardly readable and confusing, therefore marked as obsolete.
Oooops and one point more! You should also learn the difference between
CLEAR customer_tab.
and
REFRESH customer_tab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With