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 data into table

Former Member
0 Likes
5,040

Hi friends,

What are the ways to insert data into a table.

TIA.

Regards,

Mark K

7 REPLIES 7
Read only

gopi_narendra
Active Contributor
0 Likes
2,735

Create a maintenance View for the table u wnt to insert values.

SE11 --> Utilities --> Table Maintenance Generator.

SM30 --> Here you can maintain values for the tables

Regards

Gopi

Read only

Former Member
0 Likes
2,735

HI,

see the F1 help of INSERT keyword so that u can understand it simply.

for F1 help write this word in abap editor palce ur cursor on this word and press function key F1.

if it is a customer defined table with table maintainance allowed then u can enter data directly from se11

from

utilities->table contents->create.

rgds,

bharat.

Message was edited by:

Bharat Kalagara

Read only

Former Member
0 Likes
2,735

hi

1)

<b>APPEND</b> [<wa> TO / INITIAL LINE TO] <itab>.

Example:

Data: Begin of itab occurs 10,

col1 type C,

col2 type I,

end of itab.

Do 3 times.

Append initial line to itab.

itab-col1 = sy-index.

itab-col2 = sy-index ** 2.

Append itab.

Enddo.

Loop at itab.

write :/itab-col1, itab-col2.

endloop.

2)

<b>Using COLLECT statement</b>

Syntax

COLLECT [<wa> INTO] <itab>.

Example:

Data: Begin of itab occurs 3,

column1(3) type C,

column2(2) type N,

column3 type I,

End of itab.

itab-column1 = ‘abc’.

itab-column2 = ’12’.

itab-column3 = 3.

collect itab.

write /sy-tabix.

itab-column1 = ‘def’.

itab-column2 = ’34’.

itab-column3 = 5.

collect itab.

write/sy-tabix.

itab-column1 = ‘abc’.

itab-column2 = ’12’.

itab-column3 = 7.

collect itab.

write /sy-tabix.

Loop at itab.

write :/itab-column1,

itab-column2,

itab-column3.

Endloop.

3)

<b>Using INSERT statement</b>

Syntax

INSERT [<wa> INTO / INITIAL LINE INTO] <itab> [index <idx>].

Note:

New entry has index <idx> and following line has index <idx>+1.

If less than <idx>-1 entries then cannot insert line and sy-subrc = 4.

Example:

Data: Begin of line,

col1 type I,

col2 type I,

End of line.

Data itab like line occurs 10.

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.

4)

To append part or all of an internal table

Syntax

APPEND LINES OF <itab1> [FROM <n1>] [TO <n2>] TO <itab2>.

Note:

Without the FROM and TO options, this statement appends the entire table <itab1> to <itab2>.

5)

<b>To copy entire contents of one table into another in one execution</b>

Syntax

MOVE <itab1> To <itab2>.

OR

<itab1> = <itab2>.

6)

<b>MOVE-CORRESPONDING</b> <itab1> TO <itab2>.. - Executes the statement for their header lines. Searches for the sub-fields which occur both in itab1 and itab2 and

then generates, for all relevant field pairs which correspond to the

sub-fields ni , statements of the form MOVE itab1-ni TO itab2-ni. The other fields remain unchanged.

regards

ravish

<b>plz dont forget to reward points if helpful</b>

Read only

Former Member
0 Likes
2,735

HI,

1) You can create a table maintenance for that table...Then use SM30 to maintain the table

2) Create a new program to insert records to the table

Thanks

Naren

Read only

Former Member
0 Likes
2,735

hi,

By using the syntax

INSERT <database table>

u can insert the records...

and also by the transaction SE16 u can insert the datas to the table..when u go to tat transaction uhave to specify the table name and u can upload the datas..

thanks

ashu.

Read only

Former Member
0 Likes
2,735

Hi,

By using SM30 or SE16 u can enter datas directly into a table.

Otherwise,

IN SE38, using APPEND,INSERT stmts u can enter.

But in SM30 before entering data,u have to create table maintainance generator then only it will allow u to enter datas.

regards

lakshmi

Read only

Former Member
0 Likes
2,735

hi,

insering data into database tables can be done using report programs and in SE11, SM30 transaction codes.

inserting data into internal tables can be done using open sql statements

as

1. collect

2. update

3. modify

4. insert

5. insert lines of

6. move

7. append

all these statements are used accordingly when they are received for specific purposes.

if helpful reward some points.

with regards,

suresh.