2007 Jun 07 7:50 AM
Hi Friends!
Using insert can we use direct to insert record in database table its possibe whats the syntax.
2007 Jun 07 7:51 AM
Hi
INSERT
... { {VALUES wa}
| {FROM wa|{TABLE itab [ACCEPTING DUPLICATE KEYS]}} }.
1. ... {VALUES wa} | {FROM wa} ...
2. ... FROM TABLE itab [ACCEPTING DUPLICATE KEYS] ...
After FROM and VALUES, you can specify a non-table-type data object wa. After FROM, you can also specify an internal table itab. The contents of the row(s) to be inserted are taken from these data objects
Reward points for useful Answers
Regards
Anji
2007 Jun 07 7:51 AM
Hi
INSERT
... { {VALUES wa}
| {FROM wa|{TABLE itab [ACCEPTING DUPLICATE KEYS]}} }.
1. ... {VALUES wa} | {FROM wa} ...
2. ... FROM TABLE itab [ACCEPTING DUPLICATE KEYS] ...
After FROM and VALUES, you can specify a non-table-type data object wa. After FROM, you can also specify an internal table itab. The contents of the row(s) to be inserted are taken from these data objects
Reward points for useful Answers
Regards
Anji
2007 Jun 07 7:51 AM
2007 Jun 07 7:51 AM
Hi,
The Open SQL statement for inserting data into a database table is:
<b>INSERT INTO <target> <lines>.</b>
It allows you to insert one or more lines into the database table <target>. You can only insert lines into an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table <target> either statically or dynamically.
<b>Example Program</b>
TABLES SPFLI.
DATA WA TYPE SPFLI.
WA-CARRID = 'LH'.
WA-CITYFROM = 'WASHINGTON'.
...
INSERT INTO SPFLI VALUES WA.
WA-CARRID = 'UA'.
WA-CITYFROM = 'LONDON'.
...
INSERT SPFLI FROM WA.
SPFLI-CARRID = 'LH'.
SPFLI-CITYFROM = 'BERLIN'.
...
INSERT SPFLI.
Regards
Sudheer
2007 Jun 07 7:52 AM
Hi Rahul
You can NOT use option accepting duplicate keys with wa.
Option accepting duplicate keys only work with table itab NOT wa.
INSERT dbtab FROM TABLE itab. or
INSERT (dbtabname) FROM TABLE itab.
Additions
... CLIENT SPECIFIED
... ACCEPTING DUPLICATE KEYS
Please try to build internal table.
data: begin of itab occurs 0.
include structure zcitorderout.
data: end of itab.
data: wa_zcitorderout like zcitorderout.
wa_zcitorderout-vbeln = nast-objky.
itab = wa_zcitorderout.
append itab.
insert zcitorderout from table itab accepting duplicate keys.
Regards,
Sree
2007 Jun 07 7:53 AM
Hi Rahul,
check this link,
https://forums.sdn.sap.com/click.jspa?searchID=3029349&messageID=1528170
Thanks.
2007 Jun 07 7:53 AM
Yes it is possible.
INSERT <Table name>.
But not advisable.
Regards,
SaiRam
2007 Jun 07 7:56 AM
Hi Rahul,
1. INSERT INTO dbtab VALUES wa. oder
INSERT INTO (dbtabname) VALUES wa. oder
INSERT dbtab FROM wa. oder
INSERT (dbtabname) FROM wa.
2. INSERT dbtab FROM TABLE itab. oder
INSERT (dbtabname) FROM TABLE itab.
3. INSERT dbtab. oder
INSERT *dbtab.
Effect
Inserts new lines in a database table (see relational database). You can specify the name of the database table either in the program itself in the form dbtab or at runtime as the contents of the variable dbtabname. In both cases, the database table must be defined in the ABAP Dictionary. By default, data is only inserted in the current client. Data can only be inserted using a view if the view refers to a single table and was defined in the ABAP Dictionary with the maintenance status "No restriction".
INSERT belongs to the Open SQL command set.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs.See Open SQL and Unicode.
Notes
You cannot insert a line if a line with the same primary key already exists or if a UNIQUE index already has a line with identical key field values (with regard to this UNIQUE index).
When inserting lines using a view, all fields of the
database table that are not in the view are set to their initial value
(see TABLES) - if they were defined with NOT NULL in the ABAP Dictionary. Otherwise they are set to NULL.
Authorization checks (see The SAP Authorization Concept) are not supported by the INSERT statement. You must include these in the program yourself.
Lines specified with the INSERT command are not finally added to the database table until after a database commit (see Logical Unit of Work (LUW)). Prior to this, you can cancel any changes to the database with a database rollback (see Programming Transactions).
In the dialog system, you cannot rely on the locking mechanism used by the database system (see Database Locking) to synchronize simultaneous access to the same database by several users. Therefore, it is often necessary to use SAP's locking mechanism (see SAP Locking).
PS: please reward if useful..