‎2009 Feb 13 8:16 AM
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
‎2009 Feb 13 8:19 AM
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
‎2009 Feb 13 8:29 AM
its not working, the table AWB is from external database where I access using dbconnect & native sql command
‎2009 Feb 13 8:32 AM
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
‎2009 Feb 13 8:20 AM
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
‎2009 Feb 13 8:22 AM
Hi,
Try using,
INSERT INTO TABLE it_awb VALUES WA_AWB .APPEND LINES OF TABLE IT_AWB TO AWB.Hope this helps.
‎2009 Feb 13 8:25 AM
‎2009 Feb 13 8:28 AM
Please use
INSERT/UPDATE/MODIFY dtab FROM TABLE itab.
APPEND wont work for data base update.
Try checking the EXEC functionality by pressing F1...
‎2009 Feb 13 8:32 AM
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
‎2009 Feb 13 8:55 AM
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
‎2009 Feb 13 8:56 AM
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.
‎2009 Feb 13 9:06 AM
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
‎2009 Feb 13 9:23 AM
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
‎2009 Feb 16 1:50 AM
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 ?
‎2009 Feb 16 6:40 AM
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
‎2009 Feb 16 6:53 AM
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
‎2009 Feb 16 7:11 AM
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).
‎2009 Feb 16 7:30 AM
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
‎2009 Feb 16 7:46 AM
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