‎2022 Apr 07 10:39 AM
Hi experts,
As I am trying to insert same primary key to a custom table ,there is no dump and the data is normally saved to the custom table,not dump.Why is this happening?
INSERT zhx_ficot015i FROM TABLE gt_tb_di.
The same data exists in gt_tb_di and zhx_ficot015i ,but sy-subrc return 0.
codes:
DATA:gw_ficot015i TYPE zhx_ficot015i,
gt_ficot015i TYPE TABLE OF zhx_ficot015i.
gw_ficot015i-mandt = '500'.
gw_ficot015i-od_type = '02'.
gw_ficot015i-receno = 'F510320220420004'.
gw_ficot015i-itemno = '000001'.
APPEND gw_ficot015i TO gt_ficot015i.
INSERT zhx_ficot015i FROM TABLE gt_ficot015i ACCEPTING DUPLICATE KEYS.
IF SY-SUBRC = 0.
ENDIF.
BREAK-POINT.


‎2022 Apr 07 3:55 PM
Please look at ABAP Documentation. The consequence of INSERT ... FROM TABLE ... with data which would lead to duplicate keys in the table is:
‎2022 Apr 07 3:56 PM
If it's another case, check SAP notes or contact SAP support.
‎2022 Apr 07 5:52 PM
For a detail analysis I would change the INSERT ... FROM TABLE to a single INSERT in a LOOP-statement. Just to find out which record is responsible for the dump.
But sandra.rossi is right, you should indeed consider to catch the related exception if you want to stay by this variant using INSERT ... FROM TABLE.
It would be also an option to change it to MODIFY ... FROM TABLE, then there is no issue anymore in case of an existing record in the table with the same key (as it will be just updated in this case).
Kind regards
Jens
‎2022 Apr 08 2:39 AM
same primary key insert from wa or table not dump.Only this table will show this situation.
indicate ACCEPTING DUPLICATE KEYS , SY-SUBRC still return 0.

‎2022 Apr 08 6:09 AM
If the previous record came from somewhere else (like an integration); it might be the case that one of the columns contains an additional special character which can't be displayed by SAPGUI. Characters like TAB, CR, LF, etc are typical examples.
If that's the case, the system rightly thinks that the old value (containing the rogue character) is different from your clean value.
You might want to inspect the table contents through an external non-SAP tool and see if it shows such a rogue character. Checking string length is also an approach.
‎2022 Apr 08 7:54 AM
Codes:search by primary key have 12 records now.
It should not be the cause of abnormal characters.
SELECT * INTO TABLE @DATA(gt_ficot015i) FROM zhx_ficot015iAND itemno = '000001'.

‎2022 Apr 08 7:45 AM
Hello,
strange. When showing the database object (in SE11 > Utilities > Database Object > Display), is the primary index ZHX...~0 shown as "Unique" (like usually)?
‎2022 Apr 08 8:01 AM
Is the index the cause of this problem?
I'm not sure about the indexes

‎2022 Apr 08 8:08 AM
After checking, I found this problem.
Is it caused by this? What should I do? This table already has a lot of data

‎2022 Apr 08 8:20 AM
Hello,
so it seems the missing primary index causes the problem, that you were able to insert multiple rows with same primary key fields. Don't know how this could happen (except deleting it on database level). With the database utility (Utilities > Database Object > Database Utility) you can try to fix this by choosing "Persist data" and clicking "Activate and adjust database". In front of this duplicates of the primary key fields should be deleted, otherwise I guess the database utility will fail. And I would think about extracting / back up the data in front of this (by using a transport request or R3trans or a self-developed ABAP).
‎2022 Apr 08 8:36 AM
I have delete the duplicates records,then tried clicking "Activate and adjust database" ,Promting success.
but the primary index strill missing.
‎2022 Apr 08 8:55 AM
Hello,
even after activating the table again in SE11?
Then you could try to make one of the primary key fields longer, activate it (my expectation would be that the primary index will be created again) and after it shorten the primary key field again to its original length and activate again.
‎2022 Apr 08 9:34 AM
I try change a primary key longer and add a primary key then clicking "Activate and adjust database",
cannot activate

‎2022 Apr 08 10:04 AM
Encouple the primary key fields from any value tables by using data elements CHAR2, CHAR16, CHAR6 and try it again. Then change it back to the currently used data elements and activate again.
‎2022 Apr 08 10:25 AM
I just checked the z table, Actually the duplicates records cannot delete by se16n or abap code
‎2022 Apr 08 10:34 AM
I have been confirmed that there is no duplicate data. The length of the primary key has been adjusted to cahr16, but it cannot be activated

‎2022 Apr 08 10:56 AM
Hello,
column "Data element" still shows your own data elements. Did you try to change this to CHAR16 to get rid off the search help?
‎2022 Apr 08 11:25 AM
Additional error fields that exist and I added a field bukrs as the primary key. Now I can't cancel it


‎2022 Apr 08 12:16 PM
I have the impression that the action is meanwhile somewhat... chaotic. Still using the data elements bound to search helps? My idea was to replace these data elements by simple CHAR... data elements for getting rid of most dependencies to finally enable the activation of the database table with a valid, unique primary key.
‎2022 Apr 08 12:25 PM
The primary key added accidentally in the test cannot be deleted. This problem really has a great impact
‎2022 Apr 08 12:33 PM
‎2022 Apr 08 12:45 PM
‎2022 Apr 08 1:02 PM
Did you try SE14 again ("Persist data" > click on "Activate and adjust database")?
‎2022 Apr 08 1:37 PM
‎2022 Apr 08 3:46 PM
Maybe the dependency to the search help prevents you from adjusting the database table. I would try to deactivate / delete it (and restore it afterwards when everything is fine again). The long text for this message still points to SE14.

‎2022 Apr 08 3:48 PM
Ah, no, it's not pointing to SE14, it's pointing to the dependent tables.
‎2022 Apr 11 3:02 AM
Thank you very much for your patient answer. I have solved the problem. The past two days are weekends and I'm sorry I didn't reply to you in time.
Can you tell me in detail how to back up and restore data? I can only use ABAP toi obtain data from excel and then import it into the system again.
‎2022 Apr 11 8:45 AM
Hello,
great, that you could solve it!
Regarding back up and restore data there are several options available. You can create a transport request and include the data by using object key "R3TR TABU <table name>".

You have to specify the table keys (double click on the line), where you can enter "*" for all records in all clients. By releasing the transport request the data will be written out into a data file. For restoring the data you can import the transport request again.
Another option would be using R3trans (which is also used in the transport request). For this you have to work on OS level, using command files for export and import. Find here a documentation.
Another option (the easiest one, I would state) would be using the product of my company (also using R3trans). For more information on this just click on my profile and follow the link under "Elsewhere" in the "About" part.
‎2022 Apr 11 9:31 AM
The data is from 500 client and I have create requests and relasing,but how can I restoring the data to 500
client. Using code scc1 import the requesting message: Source client is same as logon client


‎2022 Apr 11 9:44 AM
‎2022 Apr 11 9:55 AM
the data is dev system data,relasing the request can only accceping in producing sysytem,
This is not the result I want.
‎2022 Apr 11 10:00 AM
‎2022 Apr 11 10:13 AM
Hello,
for the aim to backup table data for a possibly later restore on D / Q / P system you need to create a transport request on each system (assuming that the data on D / Q / P is different). For this purpose I would choose type "Transport of copies".
I advise to contact your basis administrator(s). If you are a developer, likely you do not have authorizations to import transport requests or to manage the import queue (adding / removing transport requests), so you are dependent on the basis team and should ask for their support and know-how.
‎2022 Apr 11 10:32 AM
I have authorizations to manage request.I want to back up and restore Q / P system data.
When I back up and restore Q system data,
First, I create a request in Q system data ,and delete the the data for Specifies table in Q system
,then relasing the request,how to restore the table data at Q system?
I think the ways is suitable to tranport the data from Q system data to P systrem,
cannot be backup and restore on the same system.
‎2022 Apr 11 11:13 AM
Hello,
is your recent question still about the problematic table of the original question or is this a complete new issue?
However, I can not say more about backup / restore of table data than I have already written. Using transport requests I would choose type "Transport of copies" which bypass the automatic delivery into other systems resp. their import queues. If your task is to do this on Q and P, you need 2 transport requests, one from Q and one from P. And for restoring the data you have to import the data of the transport request back again into its source system, using STMS.
‎2022 Apr 11 12:51 PM
‎2022 Apr 11 12:59 PM
Hello,
the transport of copies needs a target, to be specified on tab "Properties".

I recommend to contact your basis admin.
‎2022 Apr 11 1:34 PM
I know how to create request and accept in the same client ,but result is not effect,after recovering the table remains zero records

‎2022 Apr 11 1:36 PM