Monday 4 June 2012

Ways to Declare Internal Table in SAP-ABAP

Internal Table Definition:
                                         Internal Table is a collection of fields which are of different types.Where we can store multiple records at a time.
The data in the internal table is going to be stored for temporary.


Here are the few ways of declaring Internal tables:



*&---------------------------------------------------------------------*
*& Report  ZINT_TAB_DECLARATIONS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZINT_TAB_DECLARATIONS.

*// INTERNAL TABLE DECLARATION BY REFERRING STANDARD DATABASE TABLE
DATA: IT_MARA TYPE STANDARD TABLE OF MARA WITH HEADER LINE.

*// DECLARING INTERNAL TABLE BY USING INCLUDE STRUCTURE
DATA: BEGIN OF IT_MARA1 OCCURS 0.
      INCLUDE STRUCTURE MARA.
DATA:  END   OF IT_MARA1.

*// DECLARING INTERNAL TABLE BY USING TYPES DECLARATION
TYPES: BEGIN OF TY_MARA,
       MATNR TYPE MARA-MATNR,
       ERSDA TYPE MARA-ERSDA,
       END   OF TY_MARA.

DATA: IT_MARA2 TYPE STANDARD TABLE OF TY_MARA.


*// INTERNAL TABLE DECLARATION BY USING NORMAL METHOD
DATA:  BEGIN OF IT_MARA3 OCCURS 0,
       MATNR TYPE MARA-MATNR,
       ERSDA TYPE MARA-ERSDA,
       END   OF IT_MARA3.

2 comments: