What is append it to it statement
The statement append it to it appends the header line named it to the body named it. The statement append it does the same thing, because the default work area is the header line. Being more succinct, the latter is usually used.
A work area mentioned explicitly in the append statement is known as an explicit work area. Any field string having the same structure as a row of the internal table can be used as an explicit work area. If a work area is not mentioned, the implicit work area (the header line) is used.
The statement append initial line to it appends a row containing initial values (blanks and zeros) to the internal table. It is the same as executing the following two statements in succession: clear it and append it.
Listing 1 below shows a sample program that appends three rows to an internal table.
Listing 1: This Program Adds Three Rows to Internal Table it from the Header Line
1 report ztx1103. 2 data: begin of it occurs 3, 3 f1(1), 4 f2(2), 5 end of it. 6 it-f1 = 'A'. 7 it-f2 = 'XX'. 8 append it to it. "appends header line IT to body IT 9 write: / 'sy-tabix =', sy-tabix. 10 it-f1 = 'B'. 11 it-f2 = 'YY'. 12 append it. "same as line 8 13 write: / 'sy-tabix =', sy-tabix. 14 it-f1 = 'C'. 15 append it. "the internal table now contains three rows. 16 write: / 'sy-tabix =', sy-tabix.
The code in Listing 1 produces this output:
sy-tabix = 1 sy-tabix = 2 sy-tabix = 3
Popularity: 26% [?]






