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

runtime error --sql command

Former Member
0 Likes
1,898

Hi All,

I'm not familar with sql command, thus get this error when put into abap, can anyone help ?

I use db connection, & the connection is fine, just that when I test append a line to the table AWB , it failed, is that sytax error ?

WA_AWB-SHIPID = '1582271'.

WA_AWB-SHIPNO = '2144399'.

WA_AWB-COURIERID = 'XXX'.

WA_AWB-COURIER = 'XXX'.

INSERT WA_AWB INTO TABLE it_awb.

EXEC SQL.

APPEND AWB FROM TABLE IT_AWB

ENDEXEC.

Thanks in advance.

Janice

18 REPLIES 18
Read only

Former Member
0 Likes
1,859

hi...

APPEND statement is related to internal table.

it is not realted to database .....

if you have to do such operation you can with

INSERT <database tablename> FROM TABLE <itab> [ACCEPTING DUPLICATE KEYS] .

accepting duplicate keys prevent it from going into run time error

regards

Read only

0 Likes
1,859

its not working, the table AWB is from external database where I access using dbconnect & native sql command

Read only

0 Likes
1,859

Hi,

Which database is SAP using for the system,

try to use modify/insert/update command of that database (oracle, or SQL etc....)

Regards,

Siddarth

Read only

Former Member
0 Likes
1,859

Hi ,

Instead of Append (it is for internal table) try INSERT.

WA_AWB-SHIPID = '1582271'.
WA_AWB-SHIPNO = '2144399'.
WA_AWB-COURIERID = 'XXX'.
WA_AWB-COURIER = 'XXX'.
INSERT WA_AWB INTO TABLE it_awb.


Insert  AWB FROM TABLE IT_AWB .

Regards

Pinaki

Read only

Former Member
0 Likes
1,859

Hi,

Try using,

INSERT INTO TABLE it_awb VALUES WA_AWB .

APPEND LINES OF TABLE IT_AWB TO AWB.

Hope this helps.

Read only

Former Member
0 Likes
1,859

Hi Janice,

APPEND AWB TO IT_AWB

Regards,

Mdi.Deeba

Read only

Former Member
0 Likes
1,859

Please use

INSERT/UPDATE/MODIFY dtab FROM TABLE itab

.

APPEND wont work for data base update.

Try checking the EXEC functionality by pressing F1...

Read only

former_member222860
Active Contributor
0 Likes
1,859

Hi,

You can try like this:

WA_AWB-SHIPID = '1582271'.
WA_AWB-SHIPNO = '2144399'.
WA_AWB-COURIERID = 'XXX'.
WA_AWB-COURIER = 'XXX'.
INSERT WA_AWB INTO TABLE it_awb.


EXEC SQL.
INSERT INTO AWB(SHIPID,SHIPNO,COUIERID,COURIER) VALUES(:IT_AWB)
ENDEXEC.

thanks\

Mahesh

Edited by: Mahesh Reddy on Feb 13, 2009 9:32 AM

Read only

0 Likes
1,859

Dear Mahesh,

still cannot, any other idea ?

error msg :

"IT_AWB" cannot be a table, a reference, a string, or contain any of these objects

Read only

Former Member
0 Likes
1,859

hi!

Append will not give any changes in the database table u can use onlt update,modify or insert on database tables

try using,

INSERT dbtab FROM TABLE itab.

Read only

0 Likes
1,859

I know, but that is for normal sap table update, now I want to insert a line of a table from external database of a legacy system (using dbconnect) . I need a native sql command

Read only

former_member222860
Active Contributor
0 Likes
1,859

Hi Janice,

Try with this:

EXEC SQL.
INSERT INTO AWB(SHIPID,SHIPNO,COUIERID,COURIER) 
     VALUES(:IT_AWB-SHIPID,:IT_AWB-SHIPNO,:IT_AWB-COURIERID,:IT_AWB-COURIER)
ENDEXEC.

thanks\

Mahesh

Read only

0 Likes
1,859

Hi Mahesh,

Thanks for the answer, however it did'nt work....I think maybe because of the data type defined is not correct.

the sql table defines as this

ShipId, bigint

ShipNo, decimal(18,0),

AWB, varchar(50),

CourierID, char(3),

Amount, decimal(18,0),

courier, varchar(20),>

and I define in SAP like this :

shipid type i,

shipno(18) type p,

awb type string,

courierid(3) type c,

amount(18) type p,

courier type string,

Is this correct ? any link to refer for this data type matching ?

Read only

0 Likes
1,859

Hi Janice,

what's the error your getting..,

Anyhow let's see below the complete code example for creating table, inserting values and fetching the records.

data: begin of itab,
        shipid type i,
        shipno type p,
        awb(50) type c,
        courierid(3) type c,
        amount type p,
        courier(20) type c,
      end of itab.


itab-shipid = '1582273'.
itab-shipno = '2144340'.
itab-awb = 'mahesh'.
itab-courierid = '123'.
itab-amount = 44444.
itab-courier = 'DHL'.

*/ Table creation in Oracle DB */

*EXEC SQL.
*CREATE TABLE mahi_temp(shipid NUMBER, shipno DECIMAL(18,0), awb VARCHAR(50), courierid CHAR(3), amount DECIMAL(18,0), courier VARCHAR(20))
*ENDEXEC.

*/ Insert records into table*/

EXEC SQL.
INSERT INTO MAHI_TEMP VALUES (:itab-shipid, :itab-shipno, :itab-awb, :itab-courierid, :itab-amount, :itab-courier)
ENDEXEC.

*/ Fetching records from table */

exec sql performing list_itab.
select * from mahi_temp into :itab
endexec.

form list_itab.
write:/ itab-shipid, itab-shipno, itab-awb, itab-courierid.
endform.

Hope this helps you.

Cheers\

Mahesh

Read only

Former Member
0 Likes
1,859

Hi,

What error you are gettin. If DB connection is up then you check in debug mode what value is comming from that link in that correspondin gfield.

Regards

Md.MahaboobKhan

Read only

0 Likes
1,859

Hi Md.

This are the error:

Database error text........: "Cannot insert explicit value for identity column

in table 'AWB' when IDENTITY_INSERT is set to OFF."

Database error code........: 544

Triggering SQL statement...: "INSERT INTO AWB ( SHIPID, SHIPNO, AWB, COURIERID,

AMOUNT, COURIER ) VALUES ( ? , ? , ? , ? , ? , ? )"

Internal call code.........: "[DBDS/NEW DSQL]"

Please check the entries in the system log (Transaction SM21).

Read only

0 Likes
1,859

Hi,

I think the error says that, u've no authorization to insert into the table using the INSERT statetement.

Pl. check with the DBA, whether u've required permissions to insert the records.

thanks\

Mahesh

Read only

0 Likes
1,859

hi ,

Use the following statement...

data : wa type awb.

WA-SHIPID = ?
WA-SHIPNO = ?
WA-AWB = ?
WA-COURIERID = ?
WA-AMOUNT = ?
WA-COURIER = ?

INSERT AWB VALUES WA.
    OR 
INSERT INTO AWB VALUES WA.

THIS WORKS FOR SURE....

Rregards,

Siddarth