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

How to use INSERT query ?

Former Member
0 Likes
1,513

Frenz,

I have created one internal table and i am doing loop on it like...


Loop at it_data into wa_data.
-----
-----
-----
Endloop.

I want to insert some data into table zdata.

How to use INSERT records on this data base table?

Give me one example.

Regards,

RH

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,481

Hi,

Use the following statement for inserting the records

however the data is there in the internal table it_data.

modify zdata from table it_data.

it_data must consists of all the fields of the table zdata and importantly primary keys of the table zdata.

13 REPLIES 13
Read only

Former Member
0 Likes
1,482

Hi,

Use the following statement for inserting the records

however the data is there in the internal table it_data.

modify zdata from table it_data.

it_data must consists of all the fields of the table zdata and importantly primary keys of the table zdata.

Read only

Former Member
0 Likes
1,481

Hello

INSERT zdata FROM TABLE it_data.

Loop/endloop - here not it is necessary.

Read only

Former Member
0 Likes
1,481

Hi,

explain better what you want....

Do you want to change data in an existing raw?

Loop at tb_data into wa_data.

wa_data-field1 = 'jsahdu'.

modify tb_data from wa_data.

endloop.

If you want to add raws you use APPEND statement.

In the end you'll modify your table zdata from the internal table tb_data:

MODIFY zdata FROM TABLE tb_data.

Using modify you change raws basing on primary keys. If a raw doesn't exist it will be inserted.

Regards

Read only

Former Member
0 Likes
1,481

Hi Dude,

INSERT INTO ZDATA VALUES wa_data.

or

Insert FROM TABLE itab .

Regards,

Ramki

Read only

asik_shameem
Active Contributor
0 Likes
1,481

Hi

Do in this way.

Loop at it_data into wa_data.
-----
-----
-----
INSERT INTO ZDATA VALUES WA_DATA.
Endloop.

Read only

former_member282823
Active Participant
0 Likes
1,481

This message was moderated.

Read only

GauthamV
Active Contributor
0 Likes
1,481

hi,

check this sample code.

Loop at it_data into wa_data.

insert zgm_table from table it_data.

Endloop.

IF sy-subrc = 0.

MESSAGE 'records created succesfully' TYPE 'S'.

ENDIF.

Read only

Former Member
0 Likes
1,481

Hi,

Use your code like this.

Loop at it_data into wa_data.

ztable-field1 = wa_data-field1.

ztable-field2 = wa_data-field2.

-


-


modify ztable.

Endloop.

Otherwise you can also use the Update statement.

Regards,

Amit Kumar Singh

Read only

Former Member
0 Likes
1,481

use:

Loop at it_data into wa_data.
INSERT INTO zdata VALUES wa_data.
Endloop.

Read only

Former Member
0 Likes
1,481

Hi,

Plz try this way :

loop at it_data into wa_data.

INSERT INTO databasetable VALUES wa_data.

endloop.

but it always good to use MODIFY statement as it handles a new row insert as well as update existing row.

thanx.

Read only

Former Member
0 Likes
1,481

hi,

write Insert in ur abap editor, place the cursor on it and press F1.

U will get all the details.

Anyhow, in this case-

Insert into <tablename> values <workarea name>.

Hope this helps u.

Regards,

Aleem.

Read only

Former Member
0 Likes
1,481

Thanks