You are currently viewing Work Areas and Internal Tables in ABAP SAP

Work Areas and Internal Tables in ABAP SAP

In this article we will be taking a brief look on Work Areas and Internal Tables in ABAP, SAP.

Work Area: A Work Area is a structure which can hold single record at a time in the ABAP Program. It is very useful for any change in internal tables or database tables.
Syntax 1:

<WORK_AREA> TYPE <Z_TABLE> .

Syntax 2:

<WORK_AREA> LIKE <T_TABLE>.

WORK_AREA is name of work area.
Z_TABLE is name of database table which is defined in ABAP Dictionary.
T_TABLE is name of structure which is defined in ABAP Program.

 

Internal Table: An Internal Table is a table which can hold multiple records in the ABAP Program.

Syntax 1:

<ITAB> TYPE <Z_TABLE> OCCURS n.

Syntax 2:

<ITAB> TYPE <T_TABLE> OCCURS n.

ITAB is name of Internal Table.
Z_TABLE is name of database table which is defined in ABAP Dictionary.
T_TABLE is name of structure which is defined in ABAP Program.

 

Difference between TYPE and LIKE:

TYPELIKE
By using TYPE, it allocates memory to internal table or work area at runtime or at the time of execution.By using LIKE, it allocates memory to internal table or work area immediately in the Program.
Refers to User Defined Data Types.Refers to existing Data Type of Data Object.
Assign Data Type Directly to data object.Assign Data Type indirectly to data object.

 

Various Methods of Declaring Work Area and Internal Table
Using LIKE

DATA: BEGIN OF T_BILL, 
	INCLUDE STRUCTURE ZBILL.
DATA: MATNR TYPE NUM10,
	 MTART TYPE CHAR50,
	END OF T_BILL.
DATA: WA_BILL LIKE T_BILL,
ITAB_BILL LIKE T_BILL OCCURS 0,
IT_BILL LIKE T_BILL OCCURS 0 WITH HEADER LINE.

BEGIN OF specify start of declaration and END OF specify end of declaration. T_BILL is name of structure. INCLUDE STRUCTURE is used to add structure of ABAP Dictionary Object i.e. ZBILL is a database table defined in ABAP Dictionary. By this way you can also add other fields in the structure ie. You can create a customize structure in ABAP Program

 

Using TYPE

DATA: WA_BILL TYPE ZBILL,
ITAB_BILL TYPE ZBILL OCCURS 0,
IT_BILL TYPE ZBILL OCCURS 0 WITH HEADER LINE.

In both above methods, WA_BILL is work area. ITAB_BILL and IT_BILL are internal tables where IT_BILL is also act as a work area and internal table both due to WITH HEADER LINE which defines its structure. IT_BILL is structure and IT_BILL[ ] is internal table. OCCURS 0 defines internal table contains multiple records and allocate initial memory of 8KB to internal table and it provides or allocates initially space for 0 records in the roll area but it will increases record by record. If you use OCCURS 5 instead of OCCURS 0 then it allocates initially space for 5 records and increases 5 records by 5 records but maximum limit in the roll area is 8KB.

 

Dinesh Kumar Bansal

Dinesh Kumar Bansal is an Indian Software Developer, who is working on ASP.Net, MS-SQL, SAP-ABAP technologies from last one year. His Basic Principle of developing software is, “You have to clear about, what do you want to do, how can it be done”. He always says that development can be done with a cool & fresh mind.

Leave a Reply