Wednesday, March 18, 2009

SAP ABAP : Structure, Internal Table, Transparent Table

These confused me a lot. Finally, I wrote something to clear my doubts.

* Transparent Table: SAPLANE
* Internal Table: TY_PLANETYPES
* Structure: Z07_SAPLANE

*Possible ways of typing data object with structure, trans. table and internal table.

TABLES: SAPLANE. "=> Equivalent to DATA: SAPLANE TYPE SAPLANE. [Structure of SAPLANE with the name of SAPLANE]

DATA: t_1 TYPE SAPLANE, "=> Structure of SAPLANE.
t_2 TYPE LINE OF TY_PLANETYPES, "=> Structure of TY_PLANETYPES
t_3 TYPE TY_PLANETYPES, "=> Internal Table of TY_PlANETYPES
t_4 TYPE TABLE OF SAPLANE, "=> Internal Table of SAPLANE
t_5 TYPE TABLE OF TY_PLANETYPES, "=> Single Column Internal Table that listing Internal Table of TY_PLANETYPES.
t_9 LIKE LINE OF t_4, "=> Structure of SAPLANE.
t_10 LIKE LINE OF t_5, "=> Structure of TY_PLANETYPE.
t_12 TYPE TABLE OF SAPLANE WITH HEADER LINE, "=> t_12 is both a Structure and Internal Table. This is obsolete and please avoid using this. SAP OOP prohibited this syntax.
t_13 LIKE LINE OF t_12, "=> ABAP refer t_12 as Internal Table, and form a structure of SAPLANE.
t_14 TYPE Z07_SAPLANE, "=> Structure of Z07_SAPLANE
t_15 TYPE TABLE OF Z07_SAPLANE. "=> Internal Table with Z07_SAPLANE structure.

"t_6 TYPE LINE OF t_1. => SYNTAX ERROR: TYPE a data object with a data object?
"t_7 LIKE LINE OF TY_PLANETYPES. => SYNTAX ERROR: A data object must come after LIKE.
"t_8 LIKE LINE OF t_2. => SYNTAX ERROR: LINE OF a structure?
"t_11 TYPE LINE OF SAPLANE => SYNTAX ERROR: SAPLANE is not internal table. Can't use LINE OF.


Phew! Hopefully these covers everything.

No comments: