Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

insert statement

Former Member
0 Likes
696

how to insert large amount of data from internal table to database table

it holds the same structure as well

when i do insert it is not getting inserted

i am using the follwoing statement

insert into prps values int_prps

int_prps hold about 20,000 records

please help our to solve the issue?

regards

senthil

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
665

hi Senthil,

you can find answer easily in SAPHelp...

in your code click on INSERT statement and press F1!

insert into prps values int_prps ==> this will insert one line (i.e. header line of int_prps)

correct : insert into prps FROM TABLE int_prps

ec

5 REPLIES 5
Read only

Former Member
0 Likes
665

Hi Senthil,

do like this

insert PRPS from table int_prps.

commit work.

Reward points if it helps,

Satish

Message was edited by:

Satish Panakala

Read only

JozsefSzikszai
Active Contributor
0 Likes
666

hi Senthil,

you can find answer easily in SAPHelp...

in your code click on INSERT statement and press F1!

insert into prps values int_prps ==> this will insert one line (i.e. header line of int_prps)

correct : insert into prps FROM TABLE int_prps

ec

Read only

Former Member
0 Likes
665

insert into dbtab from table itab [accepting duplicate keys].

[accepting duplicate keys] is not mandatory it will avoid the error if any duplicate key fields you are trying to insert.

regards

shiba dutta

Read only

Former Member
0 Likes
665

hi senthil,

try using this stmt.

insert <DB table> from table <itab>.

if sy-subrc eq 0.

commit work.

endif.

<b><i>Reward points if useful</i></b>

chandra

Read only

Former Member
0 Likes
665

Hi,

Inserting Several Lines

To add several lines to an internal table, use the statement:

INSERT LINES OF itab1 INTO itab2 [INDEX idx].

The system inserts the lines of the entire table itab1 one by one into itab2 using the same rules as for single lines. itab1 can be any type of table. The line type of itab1 must be convertible into the line type of itab2.

When you append an index table to another index table, you can specify the lines to be appended as follows:

INSERT LINES OF itab1 [FROM n1] [TO n2] INTO itab2

[INDEX idx].

n1 and n2 specify the indexes of the first and last lines of itab1.

Depending on the size of the tables and where they are inserted, this method of inserting lines of one table into another can be up to 20 times faster than inserting them line by line in a loop.

Example

REPORT demo_int_tables_insert_ind_1.

DATA: BEGIN OF line,

col1 TYPE i,

col2 TYPE i,

END OF line.

DATA itab LIKE TABLE OF line.

DO 2 TIMES.

line-col1 = sy-index.

line-col2 = sy-index ** 2.

APPEND line TO itab.

ENDDO.

line-col1 = 11. line-col2 = 22.

INSERT line INTO itab INDEX 2.

INSERT INITIAL LINE INTO itab INDEX 1.

LOOP AT itab INTO line.

WRITE: / sy-tabix, line-col1, line-col2.

ENDLOOP.

The list output is:

1 0 0

2 1 1

3 11 22

4 2 4

The example creates an internal table itab and fills it with two lines. A new line containing values is inserted before the second line. Then, an initialized line is inserted before the first line.

ExampleInserting Several Lines Through Index

REPORT demo_int_tables_insert_ind_2.

DATA: BEGIN OF line,

col1 TYPE i,

col2 TYPE i,

END OF line.

DATA itab LIKE TABLE OF line.

DO 2 TIMES.

line-col1 = sy-index.

line-col2 = sy-index ** 2.

APPEND line TO itab.

ENDDO.

LOOP AT itab INTO line.

line-col1 = 3 * sy-tabix. line-col2 = 5 * sy-tabix.

INSERT line INTO itab.

ENDLOOP.

LOOP AT itab INTO line.

WRITE: / sy-tabix, line-col1, line-col2.

ENDLOOP.

The list output is:

1 3 5

2 1 1

3 9 15

4 2 4

The example creates an internal table itab and fills it with two lines. Using a LOOP construction, the program inserts a new line before each existing line.

Example

REPORT demo_int_tables_insert_ind_3.

DATA: BEGIN OF line,

col1 TYPE i,

col2 TYPE i,

END OF line.

DATA: itab LIKE TABLE OF line,

jtab LIKE itab.

DO 3 TIMES.

line-col1 = sy-index. line-col2 = sy-index ** 2.

APPEND line TO itab.

line-col1 = sy-index. line-col2 = sy-index ** 3.

APPEND line TO jtab.

ENDDO.

INSERT LINES OF itab INTO jtab INDEX 1.

LOOP AT jtab INTO line.

WRITE: / sy-tabix, line-col1, line-col2.

ENDLOOP.

The list output is:

1 1 1

2 2 4

3 3 9

4 1 1

5 2 8

6 3 27

The example creates two internal tables of the same type. Each is filled with three lines. Then, the entire table itab is inserted before the first line of jtab.

Hope this helps.

Reward points if useful.

Regards,

Subha