‎2006 Dec 27 6:38 PM
‎2006 Dec 27 6:46 PM
Hi
Can I use insert statement to insert into internal table. or can i use insert instead of append
‎2006 Dec 27 6:41 PM
INSERT statement inserts a single record into the database table.
Syntax
Tables: sflight.
Sflight-carrid = ‘LH’.
Sflight-connid = ‘234’.
Insert sflight.
Table sflight is inserted with the record. The SY_SUBRC is returned for this statement. If the entry already exists then the SY_SUBRC is set to non-zero value and you can do processing for existing record by giving some error message.
Both APPEND and INSERT add records..
As far as I know we generally use APPEND statement when we are adding lines to an Internal table...
Award points if found helpful
‎2006 Dec 27 6:43 PM
Append command is used to insert a new record in to an internal table.
insert is used to update Table.
‎2006 Dec 27 6:44 PM
Hi,
<b>Insert:</b>
INSERT [{<wa>|INITIAL LINE} INTO] <itab> [INDEX <idx>].
Inserts a new line into table. For tables with a header line the source area can be omitted. With INDEX option, the new line is inserted before the line which has the index <idx>. After the insertion, the new entry has the index <idx> and the index of the following lines is incremented by 1.
If the table consists of <idx> - 1 entries, the system appends the new entry after the last existing table line. If the table has less than <idx> - 1 entries, the system cannot insert the entry: SY-SUBRC = 4. If success, SY-SUBRC = 0.
Use INSERT without the INDEX option is allowed only within a LOOP - ENDLOOP loop by inserting the new entry before the current line (i.e. the line which has the index returned by SY-TABIX).
INSERT LINES OF <itab1> [FROM <idx1>] [TO <idx2>] INTO <itab2> [INDEX <idx>].
Inserts lines from one table into another table. Default inserts entire table. Can be up to 20 times faster than inserting lines line by line in a loop.
<b>
Appending Lines:</b>
APPEND [{<wa>|INITIAL LINE} TO] <itab>.
Appends a new line to table. For tables with a header line the source area can be omitted. After statement, the SY-TABIX contains the index of the appended line.
APPEND LINES OF <itab1> [FROM <idx1>] [TO <idx2>] TO <itab2>.
Appends lines from one table to another table. Default appends entire table. After statement, the SY-TABIX contains the index of the last appended line. About 3 to 4 times faster than appending lines line by line in a loop.
APPEND [<wa> TO] <itab> SORTED BY <f>.
Inserts the new line so that the internal table <itab> is sorted in descending order by the field <f>. If you use the SORTED BY option, the table can contain only the number of lines specified in the OCCURS parameter. If you add more lines than specified, the last line is discarded. This is useful for creating ranked lists of limited length (e.g. "Top Ten"). For ranked lists containing more than 100 entries, use instead the SORT for performance reasons.
‎2006 Dec 27 6:48 PM
‎2006 Dec 27 6:46 PM
Hi
Can I use insert statement to insert into internal table. or can i use insert instead of append
‎2006 Dec 27 6:48 PM
‎2006 Dec 27 6:54 PM
Hi,
Thanks for the answer. I have some more doubt.
If I use append where will the value be stored in header or the body. and what about insert.If I just use
Insert itab.
will it be inserted in the first index. then if I use the same statement the second time what will happen to the first value
‎2006 Dec 27 7:02 PM
‎2006 Dec 27 7:03 PM
Thanks for the answer. I have some more doubt.
If I use append where will the value be stored in header or the body. and what about insert.If I just use
Insert itab.
will it be inserted in the first index. then if I use the same statement the second time what will happen to the first value
‎2006 Dec 27 7:07 PM
it stores from header to body
insert itab.
will it be inserted in the first index. then if I use the same statement the second time what will happen to the first value
here it increases the index.
index is used to place the record in specific location.
‎2006 Dec 27 7:30 PM
‎2006 Dec 27 7:09 PM
select statement retrive the record and places in header.
append statement moves the record from header to body.