You are on page 1of 5

INTERNAL TABLE AND WORKAREA AND THEIR OPERATIONS Chain operator(:): The chain operator will combine multiple

declarations using one key word. Data:x(8) type C. DATA: Y(9) TYPE C. DATA:Z(12) TYPE C. Above can be written like below using chain operator (:) Data: X(8) TYPE C, Y(9) TYPE C, Z(12) TYPE C. Internal table: it is used to hold the multiple records and it is a temporary storage location in application server.i.e the data inside an internal table was not saved anywhere in SAP. Internal tables are dynamic memory storage locations and hence need not to provide the size. The scope of an internal table is inside a program only. One of the syntax for declaring internal table DATA <int tab> LIKE TABLE OF <DB table>. Or DATA <int tab> LIKE TABLE OF <STRUCTURE>. Ex: Data it_tab like table of zstd. (ZSTD is a database table) WORKAREA: It is used to hold once record at a time and also it is used to increase performance of the data processing. Syntax: DATA <WA> like line of <int tab> Ex: DATA wa_std like line of it_std.

Different type of syntax for declaring the internal table 1) If we require all the fields from Database(DB) table DATA:Begin of <int tab>, INCLUDE STRUCTURE <DB name>, End of <int tab>. Ex: Data: begin of it_std, Include structure ZSTD, End of it_std. 2) If we require all the fields from one table and some of the fields from another table Syntax:

DATA: Begin of <int tab>, Include structure <DB name>, F1 like <DB2-f2>, F2 like <DB2-F2>, End of <int table>. (F1,F2 are fields from database table DB2) Ex: Data:begin of it_tab, Include structure zstd, Hno like zaddr-hno, Strt like zaddr-strt, Cty like zaddr-cty, End of it_tab. 3) When ever we are decleraring int table by reffering DB (all the fields from db table will be included into the int table & WA) Syntax: Data: <wa> like <DB>, <int tab> like table of <WA>. Ex: DATA: wa_zstd like zstd, It_zstd like table of wa_zstd. 4) Declaring the int table and wa using TABLES key word Syntax: Tables <DB name> Example: Tables ZSTD Note: using tables key word, int table and wa will be created with the name of DB . 5) Int table declaration using occurs Data: Begin of <int tab> occurs 0, F1 like <db-f1>, F2 like <db-f2>, End of <int tab>. Note: occurs 0 will allocate 8kb of memory as a default to the int table. 6) When ever the workarea and int table will be separated using Data key word Syntax for Wa & Int table Data: Begin of <wa>, F1 like <DB-F1>, F2 LIKE <DB-F2>, ---------------------------------End of <WA>.

Data: <int tab> LIKE TABLE OF <WA>. Ex: Work area Data: begin of wa_zstd, Stdnum like zstd-stdnum, Stdnam like zstd-stdnam, Hno like zstd-hno, End of wa_zstd. Int table Data it_zstd like table of wa_zstd. 7) When ever the workarea and int table will be separated usingTYPES key word Syntax for structure TYPES: Begin of <typ>, F1 type <data element of f1>, F2 type <data element of f2>, F3 type <data element of f3>, -------------------------------, ---------------------------, End of <typ>. Data< wa> like/type <type>, <Inttab> like table of <wa>. Ex: Data: Begin of ty_zstd, Stdnum type zstdnum_de, Stdnam type zstdnam_de, --------------------------, ---------------------------, End of ty_zstd. DATA: wa_zstd like ty_zstd, It_zstd like table of wa_zstd Data moving from internal table to work area Syntax Loop at <int tab> into <wa>, -----------------------------, ----------------------------, Endloop. Data moving from work area to int table Syntax Append <wa> TO <int table>. INSERT <int tab> from <wa>. Note: using Append key word, record will be added in the int table at last.

Using Insert key word, record will be added any where in the int table based on the key.

Type of internal tables Internal tables are 2 types 1) INDEX 2) Hashed Index internal tables are again two types: 1) Standard int table 2) Sorted int table STANDARD int table: It allows duplicate records No need to maintain unique or non-unique key Record will be added to int table with APPEND key word Records will be searched using linear search Int table will be sorted using SORT key word explicitly Syntax: Data: <int_tab> like STANDARD table of <wa>. SORTED int table It doesnt allows the duplicate records At least one field should be unique/non-unique key Records will be added to int table using INSERT key word Binary search is used to search the records from int table No need to sort the int table because as a default int table will be sorted Syntax Data: <int tab> like SORTED table of <wa> with UNIQUE/NON-UNIQUE KEY <F1>. HASHED int table It also doesnt allows the duplicate records At least one field should be unique Records will be added using INSERT key word Mid- point algorithm is used to search the records from int table. Syntax Data: <int tab> like HASHED table of <WA> WITH UNIQUE KEY <F1>. Note: if key word(Standard or sorted or Hashed) is not used while declaring the int table,that int table is called as STANDARD int table. Some of the standard tables LFA1-------Vendor master table Lifnr : vendor number

Name1 : vendor name Ort01 : city KNA1 ------ Customer master table Kunnr : customer number Name1 : name of the customer Ort01 : City MARA --------- material master Matnr : material number VBAK--- sales heard VBAP---Sales item level table BKPF ----- Accounting header BSEG----- Accounting item level VBRK -------Billing header. VBRP -------Billing item level

You might also like