2007 Oct 09 1:11 PM
Hi All,
Using a function module, i am updating a z-table.
The Ztable will have the following fields.
employee id
name
date
project id
activity id
hrs spent
remarks
Now i will update the table by giving one employe number and details in function module.
If i want to update the data for SAME employee id, the system is overwriting.
I want the table to get more records on the same employee id.
How to do it?
Regards
Pavan
2007 Oct 09 1:28 PM
Hi Pavan,
First check the Key fields. When you use <b>UPDATE</b> keyword, it updates all the non-primary key fields based on the primary key combination.
Suppose you want to update even the duplicate entries, use <b>INSERT</b> keyword with the <b>ACCEPTING DUPLICATE KEYS</b>.
Hope this resolves your query.
Regards
Nagaraj
Hi,
In this case you need to look for some unique keys which are diffrent in case then you use that field to update the table
regards
Shiva
2007 Oct 09 1:13 PM
Hi,
Try like this
UPDATE ZTABLE FROM TABLE ITAB ACCEPTING DUPLICATE KEYS.
Reward if helpful.
Regards,
Nagaraj
2007 Oct 09 1:13 PM
Do you have one Key field or more than one.
Make atleast 3 key fields.
2007 Oct 09 1:13 PM
Hi Pavan,
Check your primary key. If your employee id is the primary key for your table means you can not insert duplicate values.
Thanks.
2007 Oct 09 1:16 PM
Hi,
In this case you need to look for some unique keys which are diffrent in case then you use that field to update the table
regards
Shiva
2007 Oct 09 1:22 PM
Hi All,
Thanks for your quick response.
In my table, employee id is a primary key.
I have observed this scenario in CATSDB table. In that table, they have used a field called "counter" to avoid this problem
How to implement the same counter kind of value in my case....????
@ Shiva,
Hi Sir, i am Pavan...your college junior at BEC, bagalkot....
Regards
Pavan
2007 Oct 09 1:30 PM
2007 Oct 09 1:28 PM
Hi Pavan,
First check the Key fields. When you use <b>UPDATE</b> keyword, it updates all the non-primary key fields based on the primary key combination.
Suppose you want to update even the duplicate entries, use <b>INSERT</b> keyword with the <b>ACCEPTING DUPLICATE KEYS</b>.
Hope this resolves your query.
Regards
Nagaraj
2007 Oct 09 1:36 PM
I am using the code as follows.
1. insert <Ztable> from <WA> accepting duplicate keys.
Error: after <WA>, period is missing.
2. insert <ztable> accepting duplicate keys.
Error: accepting is not a correct word. neither a abap statement nor a standard symbol...!!!
can you help me to some more extent?
Pavan
2007 Oct 09 1:45 PM
Hi Pavan,
Use the following syntax :
<b>INSERT <Z-TABLE> FROM TABLE ITAB ACCEPTING DUPLICATE KEYS</b>.
Hope this resolves your query.
Regards
Nagaraj
2007 Oct 09 2:00 PM
Nagaraj,
I have created an internal table same as the ztable.
now the values are dumped in internal table.
used the stament mentioned by you.
ie
INSERT <Z-TABLE> FROM TABLE ITAB ACCEPTING DUPLICATE KEYS.
While debugging, i can see sy-subrc = 4 after execution of this statement.
Kindly help me........
Regards
Pavan
2007 Oct 09 2:45 PM
Hi Pavan,
The previous syntax was litting misleading.
Use the following syntax :
<b>INSERT INTO <Z-TABLE> FROM TABLE ITAB ACCEPTING DUPLICATE KEYS.</b>
Hope this resolves your query.
Regards
Nagaraj
2007 Oct 10 7:09 AM
Nagaraj,
The statment provided by you doesn't work.
Any other idea?
Regards
Pavan
2007 Oct 10 9:41 AM
Hi Pavan,
My suggestion is to add a key field containing serial number with type NUMC ,
and at every insertion to the table you should ensure this field is unique,
by select max( this_field ) first and then increment the value ,
only then it is valid to have duplicate employee ID in your database table.
It may be possible to create duplicate primary key,
but it is not the standard , isn't it ?
Rgds,
Tuwuh Sih Winedya
Rgds
Tuwuh Sih Winedya
2007 Oct 10 9:50 AM
Hi,
If you look at CATSDB table, they have made counter as primary key and kept Pernr as non-key field.
Like that you maintain one more field similar to counter.
2007 Oct 11 5:14 AM
Jayanti,
I have gone thorugh the CATSDB Table.
How to make counter kind of field in my ztable?
I believe something needs to be done after defining "counter" filed in the table.
Can anyone guide me....????
Regards
Pavan
2007 Oct 17 11:51 AM
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |