Presentation is loading. Please wait.

Presentation is loading. Please wait.

ABAP/4 PROGRAMMING Internal Table 講 師:呂 昇 燦 2000 年 9 月 26 日.

Similar presentations


Presentation on theme: "ABAP/4 PROGRAMMING Internal Table 講 師:呂 昇 燦 2000 年 9 月 26 日."— Presentation transcript:

1 ABAP/4 PROGRAMMING Internal Table 講 師:呂 昇 燦 2000 年 9 月 26 日

2 Internal Table Internal table is a temporary table stored in RAM on the application server. It is created and filled by a program during execution and is discarded when the program ends. An internal table consists of a body and an optional header line.

3 Data: begin of it occurs 0, f1(1), f2(2), end of it. header line it f1f2 body it Definition The definition of an internal table named it. It contains two fields f1,f2.

4 Add data and Read data append [wa to] [initial line to] it. loop at it [into wa] [from m] [to n] [where exp].----- endloop. read table it [into wa] [index i | with key keyexp [binary search] ] [comparing cmpexp] [transporting texp].

5 Syntax for the sort statement sort it [descending] [as text] [by f1 [ascending|descending] [as text] f2…]

6 Advanced Internal Table(1) it[] means “the body of the internal table it if internal table it does not have a header line,you can use either it[] or it represent the body,they are equivalent Without a header line, you can perform efficient table operations

7 Information about an internal table Determining whether an internal table is empty: if it[] is initial. Determining the number of rows in an internal table: describe table it [lines i] [occurs j].

8 Copying data from one internal table to another it2[] = it1[]. Two internal tables have the same structure if –they both have the same number of components, –the data type and length of each component is the same as the corresponding of another –only the component names do not have to match

9 Using append lines /insert lines statement append lines of it1 [from nf] [to nt] to it2. insert lines of it1 [from nf] [to nt] into it2 [index nb]. User insert lines statement when you want to insert rows at a place other than the end into the target table.

10 Inserting rows into an internal table insert [wa into] it [index n] if index is specified, the new row is inserted before row n.Row n then becomes row n+1

11 Modifying rows in an internal table modify it [from wa] [index n] [transporting c1 c2 … [where exp]] transporting specifies which components are to be overwritten.

12 Exercise: Read contents of zmkpf_xx into an internal table Filling your tables zmkpf_fdevxx Use select into table Modify the usnam column so that the third row contains ‘TOM’ (use modify transporting where) Modify the mjahr, changing all ‘1994’ to ‘2000’ (use modify transporting where)

13 Deleting rows in an internal table free : delete all rows from an internal table and free the associated memory refresh : delete all rows from an internal table but leave the memory allocated clear : either clear the header line or delete all rows from it and leave the memory allocate delete : delete one or more rows from an internal table

14 Filling an internal table using collect collect [wa into] it. When collect is executed, the system forms a key from the default key fields int the wa The key composed of the values from all fields of type c, n, d, t, and x. System searches it for a row that has the same key in wa. If not, the row is appended to the end of the table.If it does find,the fields in wa are added to the corresponding row

15 Advanced Internal Table(2) Filling an internal table from a DB table: –Selecting multiple rows directly into the body of an internal table. –Selecting single rows into a work area and then appending

16 Selecting multiple rows select * –from dbtab into [corresponding fields of] table it select f1 f2 –from dbtab into [corresponding fields of] table it f1 and f2 are fields within dbtab Other additions, such as where and order by, can follow it endselect is not used with into table. select into table does not start a loop.

17 Using the corresponding fields The components of the internal table aren’t in the same order as those from database Or they don’t have the same data type and length as those from database The statement moves fields from the database table into fields of the same name in the internal table body

18 Exercise: Using internal table Sorting function with desceding Drilldown function Design a GUI status using menu painter


Download ppt "ABAP/4 PROGRAMMING Internal Table 講 師:呂 昇 燦 2000 年 9 月 26 日."

Similar presentations


Ads by Google