Application Development 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: 

INSERT

manubhutani
Active Contributor
0 Kudos

Hi

I am using the following statement

insert nast from table lt_insert

and internal table lt_insert contains two entries which are exactly same(same entries in both records)

then will it give a dump (as primary keys in both records in table lt_insert is same).so

in nast can we enter two records with exactly same primary keys.

can somebody try this scenario in the ssystem, i dont have access to create a prog in system.

Thanks

8 REPLIES 8

Former Member
0 Kudos
then will it give a dump (as primary keys in both records in table lt_insert is same).so 
in nast can we enter two records with exactly same primary keys.

Yes it will give dump and will not allow either or entry as you are trying to insert both

of them together. I have tried it my own in system and conformed the behaviour.

MarcinPciak
Active Contributor
0 Kudos

Yes it will dump out because DB can only hold unique entries (the same key combination is not allowed).

If you want that to work, first you have to delete duplicating entries from internal table, before inserting that table to DB.


DELETE ADJENCT DUPLICATES FROM lt_insert.

INSERT nast FROM TABLE lt_insert.

Regards

Marcin

Former Member
0 Kudos

hi

Primary key field will not allow duplicate records so

first try to delete the duplicate records and then try to insert into dbtable.

try this

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING <FIELDNAME>

INSERT DBTAB FROM TABLE ITAB.

Regards

0 Kudos

Hi,

you can give this a try,

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

Use of ACCEPTING DUPLICATE KEYS

If the addition ACCEPTING DUPLICATE KEYS is specified, all rows are inserted for which this is possible. The remaining rows are rejected and sy-subrc is set to 4. The system field sy-dbcnt is set to the number of lines that are inserted.

Dakshna Nagaratnam.

Former Member
0 Kudos

HI,

You should never insert entries directly into the SAP Standard tables...

0 Kudos

hi...

the use of "accepting duplicate entry" will just avoid the dump. but it wont insert the two rows with same primary keys. it will insert only one row.

but if u want the two rows any ways... just tweak the values a bit ..

these are the primary keys in NAST.

KAPPL

OBJKY

KSCHL

SPRAS

PARNR

PARVW

ERDAT

ERUHR------>Time at which status record was created

just change this value of ERUHR and then insert .. no errors will occur.

Please specify/clarify you requirements if this doesnt help

Former Member
0 Kudos

> can somebody try this scenario in the ssystem, i dont have access to create a prog in system.

So you want someone else to screw up their SAP system so that you know whether or not NAST will accept duplicate key fields, or whether the program will dump?

It is because of people like you that SAP should block direct access to tables completely and provide only "fool proof" ways of accessing data...

matt
Active Contributor
0 Kudos

>

> It is because of people like you that SAP should block direct access to tables completely and provide only "fool proof" ways of accessing data...

It's coming. Imagine all those programs that are going to have to be re-written...