Search on this Website

Wednesday, June 13, 2007

Internal Table and Types Of Internal Table



INTERNAL TABLE:

An internal table is a temporary table stored in RAM of the application server. It is created and filled by a program during execution and is discarded when the program ends.



Types of Internal Table:
1. Internal table without Header line.
2. Internal Table with header line.

INTERNAL TABLE MANIPULATIONS:

1. READ:
READ TABLE WITH KEY < fieldname =" ‘’">.

2. INSERT:
INSERT index .

3. MODIFY:
MODIFY index

4. DESCRIBE:
DESCRIBE TABLE lines OCCURS .

5. APPEND:
APPEND .

6. CLEAR
CLEAR .

7. REFRESH
REFRESH .


INTERNAL TABLE WITHOUT HEADER LINE:

DATA: BEGIN OF HEADER,
BOOKNO(4) TYPE N,
BOOKNAME(5) TYPE C,
BOOKADD(10) TYPE C,
END OF HEADER.

DATA: BODY LIKE HEADER OCCURS 0.

HEADER-BOOKNO = '1234'.
HEADER-BOOKNAME = 'SAP'.
HEADER-BOOKADD = 'TNAGAR'.
APPEND HEADER TO BODY.
CLEAR HEADER.

HEADER-BOOKNO = '1235'.
HEADER-BOOKNAME = 'ABAP'.
HEADER-BOOKADD = 'ANNANAGAR'.
APPEND HEADER TO BODY.
CLEAR HEADER.

HEADER-BOOKNO = '1236'.
HEADER-BOOKNAME = 'ERP'.
HEADER-BOOKADD = 'ADYAR'.
APPEND HEADER TO BODY.
CLEAR HEADER.

LOOP AT BODY INTO HEADER.
WRITE:/ HEADER-BOOKNO,HEADER-BOOKNAME,HEADER-BOOKADD.
ENDLOOP.



Output :


INTERNAL TABLE WITH HEADER LINE WITH MANIPULATIONS:

REPORT ZKA_INTTABWITHITAB .

DATA: BEGIN OF ITAB OCCURS 0,
BOOKNO(4) TYPE N,
BOOKNAME(5) TYPE C,
BOOKADD(10) TYPE C,
END OF ITAB.

ITAB-BOOKNO = '1234'.
ITAB-BOOKNAME = 'SAP'.
ITAB-BOOKADD = 'TNAGAR'.
APPEND ITAB.
CLEAR ITAB.

ITAB-BOOKNO = '1235'.
ITAB-BOOKNAME = 'ABAP'.
ITAB-BOOKADD = 'ANNANAGAR'.
APPEND ITAB.
CLEAR ITAB.


ITAB-BOOKNO = '1236'.
ITAB-BOOKNAME = 'ERP'.
ITAB-BOOKADD = 'ADYAR'.
APPEND ITAB.
CLEAR ITAB.


LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.

SKIP 2.

READ TABLE ITAB WITH KEY BOOKNO = '1235'.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.

SKIP 2.

READ TABLE ITAB INDEX 3.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.

SKIP 2.

ITAB-BOOKNO = '9876'.
ITAB-BOOKNAME = 'ORACLE'.
ITAB-BOOKADD = 'TAMBARAM'.


INSERT ITAB INDEX 2.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.

SKIP 2.

ITAB-BOOKNO = '4567'.
ITAB-BOOKNAME = 'BASIS'.
ITAB-BOOKADD = 'AVADI'.
MODIFY ITAB INDEX 2.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.


SKIP 2.

DELETE ITAB INDEX 2.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.

SKIP 2.

CLEAR ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.


SKIP 2.

FREE ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.


SKIP 2.

REFRESH ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.






Output :










No comments: