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 multiple values using INSERT statement ??

Former Member
0 Likes
3,491

Hi,

I want to insert two values into a custom table...Can't I say

INSERT INTO TAB VALUES X,Y.

I get the error

"Comma without preceding colon (after INSERT ?)"

why ??

thanks

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,800

The INSERT statement is use to insert ROWS not single values.

Data: xtest type ZTEST.

xtest-field1 = '1'.
xtest-field2 = '2'.
insert into ztest values XTEST.

Regards,

Rich Heilman

6 REPLIES 6
Read only

Former Member
0 Likes
1,800

Hi,

Use Update SET

UPDATE sflight SET seatsocc = seatsocc + 3

carrid = 'LH'

WHERE

connid = '0400' AND

fldate = '20010228'.

or ;

INSERT <Custom Database table>btab FROM TABLE <internal table>.

Message was edited by: Lanka Murthy

Message was edited by: Lanka Murthy

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,801

The INSERT statement is use to insert ROWS not single values.

Data: xtest type ZTEST.

xtest-field1 = '1'.
xtest-field2 = '2'.
insert into ztest values XTEST.

Regards,

Rich Heilman

Read only

0 Likes
1,800

Hello Guru's!!

I want to Insert the TABLE values of two Internal tables of Different Business Units...(Bu_zknvh & Au_Zknvh) into table Zknvh

Currently following is the CODE.. but I cant see both the Business Units data at once in the TABLE..

*... Insert Zknvh from Bu_zknvh..................

INSERT ZKNVH FROM TABLE BU_ZKNVH.

MESSAGE I002(ZM) WITH TEXT-006 SY-DBCNT.

IF SY-SUBRC <> 0 OR BU IS INITIAL.

ROLLBACK WORK.

MESSAGE E001(ZM) WITH TEXT-003.

ELSE.

COMMIT WORK.

ENDIF.

For this second internal table

I have tried using the code ..

insert into Zknvh values au_zknvh

but it inserts only one ROW.... I want to append this table with all the values of au_zknvh but it shows me an ERROR MESSAGE:: ZKNVH is not an INTERNAL TABLE ..

*... Insert ZKNVH from Table Au_zknvh...............

INSERT zknvh From table au_zknvh.

MESSAGE i002(zm) WITH text-006 sy-dbcnt.

IF sy-subrc <> 0 OR bu IS INITIAL.

ROLLBACK WORK.

MESSAGE e001(zm) WITH text-003.

ELSE.

COMMIT WORK.

ENDIF.

Please help me Thanx in advance

Preethu

Read only

0 Likes
1,800

Hi,

when u write the code 'insert into Zknvh values au_zknvh',it the gets the value from workarea(header) and inserts into the table,so only one value will be updated.

'INSERT zknvh From table au_zknvh' is the correct option to insert the data from internal tables.If still only one value is updated,then check the contents in the internal table

Cheers,

AN

Read only

0 Likes
1,800

Hi.. I dont know why if I use

'INSERT zknvh From table au_zknvh' this statement I am not getting the correct records.. but if I use 'insert into Zknvh values au_zknvh' as you said I am getting only one Record but correct one..

Cheers..

Preethu

Read only

Former Member
0 Likes
1,800

Hi Rad,

if you use insert statement with values addition it expects only one parameter (Only x or y in your case).

and X or y must be of the same structure of the table.

Moreover it creates only one record

If you want multiple records to be inserted,

then use

INSERT dbtab FROM TABLE itab.

that itab should be having the same structure as the table with as many records as you want.

Regards,

Ravi