ALV, event DATA_CHANGED, avoid insert of duplicate key
Hello,
I would like to implement edit functionality of an internal table with ALV based on class CL_GUI_ALV_GRID. Some fields of internal table are key fields and the combination of them should be unique. The user has a possibility to add a new record (all fields in new record are editable) or change values in an existing record (only non-key fields are editable). So far so good, it works.
I'm doing a validation of entered data in the event DATA_CHANGED. In this event I'm checking if the new record is a duplicate combination of existing key fields. If yes, then all fields of the new record are reported as error with ADD_PROTOCOL_ENTRY method. This removes all entries related to this row from MT_GOOD_CELLS table and this is ok for me.
My problem: after validation ALV inserts such empty row in my internal table and next time, when the user makes a correction, this record is an update and not a new record (there is no entry in MT_INSERTED_ROWS).
Question: Is there a possibility to avoid ALV inserting a new record when all its cells are bad?
Regards,
Annie
Hi,
As far as i have understood your problem,you can try the following to avoid the insertion of an empty row:
When you must be creating an empty row,just set a flag say flag_create = 'X'.
Then when you are performing the validation then if there is an error then check for this flag that is :
if flag_create = 'X'.
then delete from the internal table based on sy-tabix.
endif.
This way the new row that got appended with wrong values will get deleted and the code will not consider this as an updated row.
Kindly <<deleted> if useful.:)
Follow the rules of engagement
Edited by: Vijay Babu Dudla on Jan 9, 2012 7:07 AM
Similar Messages
-
ALV-Event data_changed after searchhelp with userdefined searchhelpexit
Hi there ...
I'm using an OO alv grid with an elementary searchhelp at defined fields.
the search help uses an searchhelpexit, that simply filters data, to show the right stuff
everything works fine!
dependent on the returned value of the searchhelp, I need to trigger a recalculation of values.
the alv-event "data_changed" looks interesting for that issue ... especially the flag "e_onf4_after" ...
BUT: I don't know, when the flag is set :$
the event is raised (with marked flags "e_onf4" and "e_onf4_before") before the Searchhelplist is displayed .... but I need to react AFTER the searchhelp is closed and the selected value is returned ...
all I want to do is:
trigger the recalculation after the user selected a value at the searchhelp
can anybody help me in that case?!
thanks a lot & enjoy your weekend
MarkusHi,
You can call elementary search help like any popup screen
with function F4IF_FIELD_VALUE_REQUEST.
- Call f4 help manually in the event DATA_CHANGED
- Process your recalculation
- set values on cells..
I hope it helps. -
Translate INSERT ON DUPLICATE KEY (mysql) to Oracle
Hello. I have the following MySQL statement:
INSERT into A
SELECT * FROM B
ON DUPLICATE KEY UPDATE A.repeated_count=A.repeated_count+1;
Therefore if the row is already in the primary key is not inserted but there is a column counting the number of times this happens (repeated_count)
Is there any equivalent in Oracle SQL? I guess I may need a trigger.
ThanksIn Oracle the counter part statement is MERGE
http://www.psoug.org/reference/merge.html -
ALV event data_changed error
Hello everybody,
I have a one editable field in ALV. After 'ENTER' I want do some actions ( check input , save data into DB table...).
CLASS lcl_gui DEFINITION CREATE PROTECTED.
PUBLIC SECTION.
DATA: mor_alv TYPE REF TO cl_gui_alv_grid,
METHODS: alv_init,
alv_changed FOR EVENT data_changed
OF cl_gui_alv_grid
IMPORTING er_data_changed,
register_events,
METHOD register_events .
CALL METHOD mor_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
SET HANDLER me->alv_changed FOR mor_alv.
ENDMETHOD.
After I change field and pres 'ENTER' I get popup with message "Programs error" and program exits.
(On the screen in other container I also have ALV Tree-CL_GUI_ALV_TREE , maybe it is impotrant to mention...)
Please help.Hi Sandeep,
as I said I just get popup wit error message "Program errors" with just "Exit" button, when I press the button program exits.
I get no runtime error, just this popup.
Regards
Jan. -
We have been seeing the following 'warnings' in the event log of our BizTalk machine since upgrading to BTS 2006. They seem to occur randomly 6 or 8 times per day.
Does anyone know what this means and what needs to be done to clear it up? we have only one BizTalk server which is running on only one machine.
I am new to BizTalk, so I am unable to find how many tracking host instances running for BizTalk server. Also, can you please let me know that we can configure only one instance for one server/machine?
Source: BAM EventBus Service
Event: 5
Warning Details: Execute batch error. Exception information: TDDS failed to batch execution of streams. SQLServer: bizprod, Database: BizTalkDTADb.Cannot insert duplicate key row in object 'dta_MessageFieldValues'
with unique index 'IX_MessageFieldValues'. The statement has been terminated..Other than ensuring that there exists a separate and single tracking host instance, you're getting an error about duplicate keys.. which implies that you're trying to Create a BAM Activity twice with the same data.
I suggest you have a in-depth examination of the BAM (TPE or API) associated with the orchestration. In TPE ensure that the first binding you select is the "Instance Id" or "Message Id" before going ahead to map the ports or others.
Regards. -
Insert statement Acepting duplicate Keys ???
Hi ,
i am updating a ztable ZMM_PRIMO_DUPERR from itab I_DPAIR .
in my ztable there is a field PROCESSING_DATE which is the only primary key .
and in my itab i have 2 records on the same processing date . i mean for a particular key, Duplicate record exists in I_DPAIR .
i want to update both records into the ztable.so i write the below code,but its not working, Its only inserting the first record ?
how this below syntax works ??
INSERT ZMM_PRIMO_DUPERR FROM TABLE I_DPAIR ACCEPTING DUPLICATE KEYS
please share your thoughts ..Hi,
Just CHeck this Documentation from SAP :
... ACCEPTING DUPLICATE KEYS
Effect
If a line cannot be inserted, the system does not
terminate with a runtime error but only sets the return value SY-SUBRC to 4. All other lines are inserted after the command is executed
i.e. so as to just avoid the dump we can use this syntax.
But we cannot insert duplicate records in a table.
Any ways if you have to insert duplicate you have to change your primary key's and table design. -
Cannot insert duplicate key row in object Error Message
Morning All,
I noticed today that the DW has not been updated with some of my CI's based off my custom class.
The event log is showing these error messages.
An error countered while attempting to execute ETL Module:
ETL process type: Transform
Batch ID: 5601
Module name: TransformPeripheralDim
Message: ErrorNumber="2601" Message="Cannot insert duplicate key row in object 'dbo.PeripheralDim' with unique index 'UniqueIndex'." Severity="14" State="1" ProcedureName="TransformPeripheralDimProc" LineNumber="163" Task="Inserting into Dimension"
Stack: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at Microsoft.SystemCenter.Warehouse.Utility.SqlHelper.ExecuteReader(SqlConnection sqlCon, CommandType cmdType, String cmdText, SqlParameter[] parameters)
at Microsoft.SystemCenter.Warehouse.Etl.StoredProcedure.Execute(IXPathNavigable config, Watermark wm, DomainUser sourceConnectionUser, DomainUser destinationConnectionUser)
at Microsoft.SystemCenter.Warehouse.Etl.TransformModule.Execute(IXPathNavigable config, Watermark wm, DomainUser sourceConnectionUser, DomainUser destinationConnectionUser)
at Microsoft.SystemCenter.Etl.ETLModule.OnDataItem(DataItemBase dataItem, DataItemAcknowledgementCallback acknowledgedCallback, Object acknowledgedState, DataItemProcessingCompleteCallback completionCallback, Object completionState)
ETL Module Execution failed:
ETL process type: Transform
Batch ID: 5601
Module name: TransformPeripheralDim
Message: ErrorNumber="2601" Message="Cannot insert duplicate key row in object 'dbo.PeripheralDim' with unique index 'UniqueIndex'." Severity="14" State="1" ProcedureName="TransformPeripheralDimProc" LineNumber="163" Task="Inserting into Dimension"
Stack: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at Microsoft.SystemCenter.Warehouse.Utility.SqlHelper.ExecuteReader(SqlConnection sqlCon, CommandType cmdType, String cmdText, SqlParameter[] parameters)
at Microsoft.SystemCenter.Warehouse.Etl.StoredProcedure.Execute(IXPathNavigable config, Watermark wm, DomainUser sourceConnectionUser, DomainUser destinationConnectionUser)
at Microsoft.SystemCenter.Warehouse.Etl.TransformModule.Execute(IXPathNavigable config, Watermark wm, DomainUser sourceConnectionUser, DomainUser destinationConnectionUser)
at Microsoft.SystemCenter.Etl.ETLModule.OnDataItem(DataItemBase dataItem, DataItemAcknowledgementCallback acknowledgedCallback, Object acknowledgedState, DataItemProcessingCompleteCallback completionCallback, Object completionState)
It was working fine so I'm not sure what's caused it to stop or where I can start looking to see what's causing it.
Any ideas?
Cheers,
SB
My System Center BlogJust in case it helps, this is the MP I'm using to bring the data across to the DW.
If I removed the MP from Service Manager, would that drop the tables in the DW and allow me to start again?
<ManagementPack
ContentReadable="true"
SchemaVersion="1.1"
OriginalSchemaVersion="1.1">
<Manifest>
<Identity>
<ID>AssetManagementReports</ID>
<Version>1.0.0.6</Version>
</Identity>
<Name>AssetManagementReports</Name>
<References>
<Reference
Alias="AssetManagemetListsRef">
<ID>AssetManagementLists</ID>
<Version>1.0.1.1</Version>
<PublicKeyToken>0a39b272096917b0</PublicKeyToken>
</Reference>
<Reference
Alias="AssetManagementMP">
<ID>AssetManagement</ID>
<Version>1.0.0.21</Version>
<PublicKeyToken>0a39b272096917b0</PublicKeyToken>
</Reference>
<Reference
Alias="DWBase">
<ID>Microsoft.SystemCenter.Datawarehouse.Base</ID>
<Version>7.0.5826.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference
Alias="System">
<ID>System.Library</ID>
<Version>7.0.5826.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
</References>
</Manifest>
<Warehouse>
<Outriggers>
<Outrigger
ID="EquipmentTypeList"
Accessibility="Public">
<Attribute
ID="EquipmentType"
PropertyPath="$Context/Property[Type='AssetManagementMP!AssetManagementBaseClass']/EquipmentType$"/>
</Outrigger>
<Outrigger
ID="ManufacturerList"
Accessibility="Public">
<Attribute
ID="Manufacturer"
PropertyPath="$Context/Property[Type='AssetManagementMP!AssetManagementBaseClass']/Manufacturer$"/>
</Outrigger>
<Outrigger
ID="ModelList"
Accessibility="Public">
<Attribute
ID="Model"
PropertyPath="$Context/Property[Type='AssetManagementMP!AssetManagementBaseClass']/Model$"/>
</Outrigger>
<Outrigger
ID="SupplierList"
Accessibility="Public">
<Attribute
ID="Supplier"
PropertyPath="$Context/Property[Type='AssetManagementMP!AssetManagementBaseClass']/Supplier$"/>
</Outrigger>
<Outrigger
ID="DirectorateList"
Accessibility="Public">
<Attribute
ID="Directorate"
PropertyPath="$Context/Property[Type='AssetManagementMP!AssetManagementBaseClass']/Directorate$"/>
</Outrigger>
<Outrigger
ID="DepartmentList"
Accessibility="Public">
<Attribute
ID="Department"
PropertyPath="$Context/Property[Type='AssetManagementMP!AssetManagementBaseClass']/Department$"/>
</Outrigger>
<Outrigger
ID="SectionList"
Accessibility="Public">
<Attribute
ID="Section"
PropertyPath="$Context/Property[Type='AssetManagementMP!AssetManagementBaseClass']/Section$"/>
</Outrigger>
<Outrigger
ID="LocationList"
Accessibility="Public">
<Attribute
ID="Location"
PropertyPath="$Context/Property[Type='AssetManagementMP!AssetManagementBaseClass']/Location$"/>
</Outrigger>
<Outrigger
ID="MobileTariffList"
Accessibility="Public">
<Attribute
ID="MobileTariff"
PropertyPath="$Context/Property[Type='AssetManagementMP!MobilePhoneNumberAsset']/MobileTariff$"/>
</Outrigger>
</Outriggers>
<Dimensions>
<Dimension
ID="PeripheralDim"
Accessibility="Public"
InferredDimension="true"
Target="AssetManagementMP!Peripheral"
HierarchySupport="IncludeDerivedClassProperties"
Reconcile="true"/>
<Dimension
ID="MobilePhonesDim"
Accessibility="Public"
InferredDimension="true"
Target="AssetManagementMP!MobilePhones"
HierarchySupport="IncludeDerivedClassProperties"
Reconcile="true"/>
<Dimension
ID="MobileSIMCardAssetDim"
Accessibility="Public"
InferredDimension="true"
Target="AssetManagementMP!MobileSIMCardAsset"
HierarchySupport="IncludeDerivedClassProperties"
Reconcile="true"/>
<Dimension
ID="MobilePhoneNumberAssetDim"
Accessibility="Public"
InferredDimension="true"
Target="AssetManagementMP!MobilePhoneNumberAsset"
HierarchySupport="IncludeDerivedClassProperties"
Reconcile="true"/>
<Dimension
ID="RemoteAccessTokenAssetDim"
Accessibility="Public"
InferredDimension="true"
Target="AssetManagementMP!RemoteAccessTokenAsset"
HierarchySupport="IncludeDerivedClassProperties"
Reconcile="true"/>
<Dimension
ID="CiscoIPTelephonyAssetDim"
Accessibility="Public"
InferredDimension="true"
Target="AssetManagementMP!CiscoIPTelephonyAsset"
HierarchySupport="IncludeDerivedClassProperties"
Reconcile="true"/>
<Dimension
ID="NetworkInfrastructureAssetDim"
Accessibility="Public"
InferredDimension="true"
Target="AssetManagementMP!NetworkInfrastructureAsset"
HierarchySupport="IncludeDerivedClassProperties"
Reconcile="true"/>
<Dimension
ID="ServerInfrastructureAssetDim"
Accessibility="Public"
InferredDimension="true"
Target="AssetManagementMP!ServerInfrastructureAsset"
HierarchySupport="IncludeDerivedClassProperties"
Reconcile="true"/>
</Dimensions>
<Facts>
<RelationshipFact
ID="MobiletoSIMCardFact"
Accessibility="Public"
Domain="DWBase!Domain.ConfigurationManagement"
TimeGrain="Daily"
SourceType="AssetManagementMP!MobilePhones"
SourceDimension="MobilePhonesDim">
<Relationships
RelationshipType="AssetManagementMP!MobiletoSIMCard"
TargetDimension="MobileSIMCardAssetDim"/>
</RelationshipFact>
<RelationshipFact
ID="MobiletoPhoneNumberFact"
Accessibility="Public"
Domain="DWBase!Domain.ConfigurationManagement"
TimeGrain="Daily"
SourceType="AssetManagementMP!MobilePhones"
SourceDimension="MobilePhonesDim">
<Relationships
RelationshipType="AssetManagementMP!MobiletoPhoneNumber"
TargetDimension="MobilePhoneNumberAssetDim"/>
</RelationshipFact>
<RelationshipFact
ID="MobilePhoneNumberToSIMCardFact"
Accessibility="Public"
Domain="DWBase!Domain.ConfigurationManagement"
TimeGrain="Daily"
SourceType="AssetManagementMP!MobilePhoneNumberAsset"
SourceDimension="MobilePhoneNumberAssetDim">
<Relationships
RelationshipType="AssetManagementMP!MobilePhoneNumberToSIMCard"
TargetDimension="MobileSIMCardAssetDim"/>
</RelationshipFact>
<RelationshipFact
ID="PeripheralOwnedByUserFact"
Accessibility="Public"
Domain="DWBase!Domain.ConfigurationManagement"
TimeGrain="Daily"
SourceType="AssetManagementMP!Peripheral"
SourceDimension="PeripheralDim">
<Relationships
RelationshipType="System!System.ConfigItemOwnedByUser"
TargetDimension="DWBase!UserDim"/>
</RelationshipFact>
</Facts>
</Warehouse>
<LanguagePacks>
<LanguagePack
ID="ENG"
IsDefault="true">
<DisplayStrings>
<DisplayString
ElementID="AssetManagementReports">
<Name>Asset
Management Reports</Name>
<Description>This
management pack adds an Asset Management dimension to the Data Warehouse and other items related to reporting.</Description>
</DisplayString>
</DisplayStrings>
</LanguagePack>
<LanguagePack
ID="ENU"
IsDefault="false">
<DisplayStrings>
<DisplayString
ElementID="AssetManagementReports">
<Name>Asset
Management Reports</Name>
<Description>This
management pack adds an Asset Management dimension to the Data Warehouse and other items related to reporting.</Description>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
</ManagementPack>
My System Center Blog -
Hi team,
How resolve the below error
Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?
Thanks,
Ram
RAMHi team,
How resolve the below error
Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?
Thanks,
Ram
RAM
There can be two reasons
1. The insert script used is having multiple instances of the records with Key as 12610 returned from the source query. If this is the issue add a logic to include only the unique set of id values for records by avoiding duplicates. There are several approaches
for this like using ROW_NUMBER with PARTITION BY, using a join with derived table etc
2. The record with Key 12610 already exist in your destination table and your script is again trying to insert another instances of record with same key. This can be avoided by adding a NOT EXISTS condition with a subquery which will check and return only
those records which doesnt already exist in the source
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Db adaptor for insert- SQLException: [SQL0803] Duplicate key value specified
While invoking db adaptor for insert on table 1 selecting values form another table, i am gtting error ; before3 insert i am updating table 2nd using db adaptor
QUERY insert into CRPDTA.F5504579 (SELECT * FROM CRPDTA.F5504571 WHERE PAHDC=#v_updatedRecord_HDC)
Error :
Non Recoverable System Fault :
<bpelFault><faultType>0</faultType><bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="summary"><summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'insert_Ledger_F5504579' failed due to: Pure SQL Exception. Pure SQL Execute of insert into CRPDTA.F5504579 (SELECT * FROM CRPDTA.F5504571 WHERE PAHDC=?) failed. Caused by java.sql.SQLException: [SQL0803] Duplicate key value specified.. The Pure SQL option is for border use cases only and provides simple yet minimal functionality. Possibly try the "Perform an operation on a table" option instead. This exception is considered not retriable, likely due to a modelling mistake. To classify it as retriable instead add property nonRetriableErrorCodes with value "--803" to your deployment descriptor (i.e. weblogic-ra.xml). To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff. All properties are integers. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary></part><part name="detail"><detail>[SQL0803] Duplicate key value specified.</detail></part><part name="code"><code>-803</code></part></bindingFault></bpelFault>
Please suggest....Easter1976 wrote:
Hi please can you help me. I think I am having problems with tranactions. I am deleting from a table and then inserting in the same table with the same key that I have just deleted. Simple then - don't do that. It suggests a flaw in the design. Either use a new key or do an update.
Note that you would get a duplicate key error if the table is set up such that it doesn't
actually delete but doesn't something such as creating a log entry with a delete flag set. -
OO ALV validation check without event DATA_CHANGED and results via popup
Hi Gurus,
I'm working on SAP ECC 6.0 and I'm facing a problem during the ALV validation check. My requirement is to show an ALV with one editable field. In addition I have to pre-initialize this field in order to give a reference value to the user, but this is not always correct, or better, this field represent the maximum amount available, but, because of other validation checks, this field is not always correct (and it's ok, it's not a problem), and if it is greater than another amount I have to display an error.
I was thinking about catching the event DATA_CHANGED and do the checks inside of it. It works but not completely, because if the user do not change anything the event is not raised and I cannot do my checks.
My solution is to do the checks without catching the DATA_CHANGED event and display the errors in a separate popup window.
The checks are ok, but I have problems during the displaying of the results: I would like to use the class CL_ALV_CHANGED_DATA_PROTOCOL in order to display the errors, I tried creating the Object:
Data: go_Error Type Ref To CL_ALV_CHANGED_DATA_PROTOCOL.
Create Object go_Error
Exporting
* i_container =
i_calling_alv = go_0200_Alv
giving it a reference to the ALV (the go_0200_Alv is my CL_GUI_ALV_GRID object).
Then I did many Call Methods to the Add_Protocol_Entry to add the message in the protocol and then display them calling the Display_Protocol Method of my "go_Error".
The Popup is shown and the "links" to the ALV are correct (if I double click a message it selects the corresponding row of the ALV, but (and it's my problem) I cannot see the Description of the Column with the error: the popup window is an ALV grid itself with 3 columns ("Message Type", "Name of the Column" and "Message Text") where I can see correctly the Message Type and the Message Text but not the name of the column.
Debugging the code I found that If I catch the event, the parameter er_Data_Changed (the class CL_ALV_CHANGED_DATA_PROTOCOL) is filled with some other informations like Modified Rows and other attributes like FieldCatalog, Row-ID, so I thought the problem was related to that, and that's why I replicated the whole case in my processing, filling every table I would see if I use the "standard way" for validation. Bu it didn't correct the error. I still don't see the name of the Column.
This is my code, it's only the part interested, If you need other informations, please ask me and I will copy them.
form CHECK_ALV_0200_0110 Changing pc_Error Type Char01.
Data: lt_MatchK1 Type tp_Matches1_Key_t,
l_Message Type Char100,
l_MessX Type String,
l_QtaRes Type ZDM_AMT_ASSIGNED,
l_QtaAcc Type ZDM_AMT_ACCRUED,
l_QtaStep Type ZDM_AMT_ASSIGNED.
Field-Symbols: <fs_Table> Type Standard Table,
<fs_Master> Type Standard Table,
<fs_Mod_Cell> Type LVC_S_MODI,
<fs_Line> Type Any,
<fs_Field> Type Any,
<fs_Any> Type Any.
Data lt_Matches_Alv_Mod Type tp_Matches1_Alv_t.
Data ls_Modi Type LVC_S_MODI.
Data: l_Row_ID Type I,
l_Tabix Type I.
Field-Symbols: <fs_Match_ALV> Type tp_Matches1_Alv_s.
Free go_Error.
CREATE OBJECT go_Error
EXPORTING
* i_container =
i_calling_alv = go_0200_Alv
* Validation Checks
Clear pc_Error.
Clear ls_Modi.
Loop At gt_Matches1_Alv Assigning <fs_Match_ALV>.
l_Tabix = Sy-Tabix.
Check <fs_Match_ALV>-Status Eq con_Status_Temp.
* Set the Modified Row for the CL_ALV_CHANGED_DATA_PROTOCOL object
Append <fs_Match_ALV> To lt_Matches_Alv_Mod.
Add 1 To ls_Modi-Row_Id.
ls_Modi-FieldName = 'AMT_DEDUCTED'.
Write <fs_Match_ALV>-Amt_Deducted To ls_Modi-Value Currency <fs_Match_ALV>-Waers.
Condense ls_Modi-Value No-Gaps.
ls_Modi-Tabix = l_Tabix.
Append ls_Modi To: go_Error->mt_Mod_Cells,
go_Error->mt_Good_Cells.
l_Row_ID = ls_Modi-Row_Id.
Clear l_Message.
If <fs_Match_ALV>-Amt_Deducted Eq 0.
pc_Error = con_X.
CALL METHOD go_Error->Add_Protocol_Entry
EXPORTING
i_msgid = 'ZDMV'
i_msgty = 'E'
i_msgno = '005'
* i_msgv1 =
* i_msgv2 =
* i_msgv3 =
* i_msgv4 =
i_fieldname = 'AMT_DEDUCTED'
i_row_id = l_Row_ID
* i_tabix =
Continue.
EndIf.
Case g_Dynnr.
When '0110'.
Perform Get_ResQtaDispute1 Using lt_MatchK1
<fs_Match_ALV>
Changing l_QtaRes.
Perform Get_ResQtaAccrued1 Using <fs_Match_ALV>
Changing l_QtaAcc.
* When '0111'.
* Perform Get_ResQtaDispute2 Using lt_MatchK2
* <fs_Match_ALV>
* Changing l_QtaRes.
* Perform Get_ResQtaAccrued2 Using <fs_Match_ALV>
* Changing l_QtaAcc.
EndCase.
Add <fs_Match_ALV>-Amt_Deducted To l_QtaStep.
If l_QtaStep > l_QtaRes.
* Store the Error
pc_Error = con_X.
Write l_QtaRes To l_Message Currency <fs_Match_ALV>-Waers.
Condense l_Message No-Gaps.
CALL METHOD go_Error->Add_Protocol_Entry
EXPORTING
i_msgid = 'ZDMV'
i_msgty = 'E'
i_msgno = '002'
i_msgv1 = l_Message
* i_msgv2 =
* i_msgv3 =
* i_msgv4 =
i_fieldname = 'AMT_DEDUCTED'
i_row_id = l_Row_ID
* i_tabix =
EndIf.
If l_QtaStep > l_QtaAcc.
* Store the Error
pc_Error = con_X.
Write l_QtaAcc To l_Message Currency <fs_Match_ALV>-Waers.
Condense l_Message No-Gaps.
CALL METHOD go_Error->Add_Protocol_Entry
EXPORTING
i_msgid = 'ZDMV'
i_msgty = 'E'
i_msgno = '002'
i_msgv1 = l_Message
* i_msgv2 =
* i_msgv3 =
* i_msgv4 =
i_fieldname = 'AMT_DEDUCTED'
i_row_id = l_Row_ID
* i_tabix =
EndIf.
EndLoop.
If pc_Error Eq con_X.
* If there was at least one error, Display the Popup
go_Error->mt_FieldCatalog[] = gt_0200_FCat[].
go_Error->ms_Layout-Zebra = con_X.
Get Reference Of lt_Matches_Alv_Mod[] Into go_Error->Mp_Mod_Rows.
CALL METHOD go_error->display_protocol
* EXPORTING
* i_container =
* i_display_toolbar =
* i_optimize_columns =
EndIf.
EndForm.
Do you know if there is a particular issue about that? Or, maybe, I'm doing something wrong...
Please help me
Regards,
Claudio
Edited by: Claudio Distrutti on Oct 31, 2008 12:38 PMHello Claudio
Nobody prevents you from calling your event handler method go_grid->HANDLE_DATA_CHANGED directly!
What do I mean with that?
I assume you are calling method go_grid->CHECK_CHANGED_DATA at the beginning of the PAI module to catch any changes from the editable ALV grid. Within the event handler method you do your validation and send the error popup if necessary.
Now when the user closes the error popup and pushes e.g. the SAVE button then I can happen that method HANDLE_DATA_CHANGED does not trigger event DATA_CHANGED because nothing was indeed changed on the ALV grid. Yet the invalid value is still there.
However within the FORM routine for saving the data you can just call your event handler method directly:
FORM save_data.
CALL METHOD go_grid->handle_data_changed
EXPORTING
* er_data_changed =
e_ucomm = 'SAVE'.
ENDFORM.
Now within your event handler method you always know when the method was called because if method CHECK_CHANGED_DATA triggers event DATA_CHANGED the IMPORTING parameter ER_DATA_CHANGED is bound whereas it is empty when the method is called from your SAVE routine.
METHOD handle_data_changed.
DATA: lo_log TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
IF ( er_data_changed IS BOUND ).
lo_log = er_data_changed.
ELSE.
CREATE OBJECT lo_log.
ENDIF.
" Do the validations and send error log if necessary
lo_log->DISPLAY_PROTOCOL( ).
ENDMETHOD.
Regards
Uwe -
Cannot insert duplicate key in ddm.log
Hello,
I have been noticing the below on many occasions:
*** IF EXISTS (select ItemKey from DiscItemAgents where ItemKey = 278482 and DiscArchKey = 5 and AgentID = 15 and AgentSite = 'auto') update DiscItemAgents set AgentTime = '07/31/2014 16:26:11' where ItemKey = 278482 and DiscArchKey = 5 and AgentID =
15 and AgentSite = 'auto'~ ELSE insert into DiscItemAgents (AgentTime, ItemKey, DiscArchKey, AgentID, AgentSite) values ('07/31/2014 16:26:11', 278482, 5, 15, 'auto')
SMS_DISCOVERY_DATA_MANAGER
8/1/2014 5:53:01 AM 4104 (0x1008)
*** [23000][2627][Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY constraint 'DiscItemAgents_PK'.
Cannot insert duplicate key in object 'dbo.DiscItemAgents'. The duplicate key value is (278482, 15, 5, aut).
SMS_DISCOVERY_DATA_MANAGER 8/1/2014 5:53:01 AM
4104 (0x1008)
CDiscoverySource_SQL::UpdateItem - could not execute sql- IF EXISTS (select ItemKey from DiscItemAgents where ItemKey = 278482 and DiscArchKey = 5 and AgentID = 15 and AgentSite = 'auto') update DiscItemAgents set AgentTime = '07/31/2014 16:26:11' where
ItemKey = 278482 and DiscArchKey = 5 and AgentID = 15 and AgentSite = 'auto'~ ELSE insert into DiscItemAgents (AgentTime, ItemKey, DiscArchKey, AgentID, AgentSite) values ('07/31/2014 16:26:11', 278482, 5, 15, 'auto')
SMS_DISCOVERY_DATA_MANAGER 8/1/2014 5:53:01 AM
4104 (0x1008)
CDiscoverDataManager::ProcessDDRs_PS - Unable to update data source
SMS_DISCOVERY_DATA_MANAGER 8/1/2014 5:53:01 AM
4104 (0x1008)
I then ran a query in SQL based on error Cannot insert duplicate key in object 'dbo.DiscItemAgents'. The duplicate key value is (278482, 15, 5, aut) : select * from DiscItemAgents where ItemKey = '278482'
I got the result stating that the record has AgentSite as 'aut'
Now when I check distinct values for AgentSite column I am able to see all site code values that are present in the hierarchy.
I, then ran a query to find the no of rows for AgentSite = 'aut'. It returned me 7 which are some client machines.
To resolve, when I run this sql query, DDM starts working fine: Delete from DiscItemAgents where AgentSite = 'aut'
Now I am wondering what makes a client send a DDR with SiteCode as 'aut' and not the assigned or reporting site code? How can I resolve this, without having to run the delete statement?
Thanks
Rajivok, We were using a custom client health solution that was creating a DDR with the site code as AUTO. The DDR process only accepts 3 digit code, which was causing the DDM to fault. Reinstalling the agent and re-configuration of the client health solution
seems to have fixed the issue.
Thanks, Rajiv -
I have migrated my SCCm 2007 environment to SCCM 2012 SP1 CU4.
I noticed in the System Status\Component Status\SMS_STATE_SYSTEM a lot of errors like the one below:
Microsoft SQL Server reported SQL message 2627, severity 14: [23000][2627][Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of PRIMARY KEY constraint 'DeploymentSummary_PK'. Cannot insert duplicate key in object 'dbo.DeploymentSummary'. The duplicate key value is (1, 0, S0220438, 0). : spUpdateClassi
Please refer to your Configuration Manager documentation, SQL Server documentation, or the Microsoft Knowledge Base for further troubleshooting information.
When looking up the deployment ID and recreate the Deployment the problem is solved. But I have 700 packages and don't want to manually do this action on all packages. I think it is related to the migration i did and something went wrong there :-(
Besides it will retriggers the deployment to the clients which is also not preferred.
Is there another way to solve this by e.e.g do something directly in the SQL database tables ?Hi,
It is not supported by Microsoft that do something directly in SQL database.
If you want to do that, you could make a call to CSS.
Best Regards,
Joyce
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
Hi,
I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
Thank you,
Bala Murali Krishna Medipally.Hi,
I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
Thank you,
Bala Murali Krishna Medipally.
I suspect you are trying to insert modified records instead of updating. -
Cannot insert duplicate key row in object
This is a JPA question. The tbHardware table has a PK identity column and a unique non-clustered index on CoxBarcode column.
I have a SFSB in a Seam2.0.0.GA app running on JBoss 4.2.1.GA. I am using flushMode=FlushModeType.MANUAL (Seam specific when beginning a conversation) and that's why you see the flush() reference at the end of the following code snippet.
Query query = entityManager.createNativeQuery("INSERT INTO tbHardware "+
"VALUES (:coxBarCode, :serialNo, :currentStatus, :currentLocationNo, "+
":desc, :hardwareModelId, :ownerTypeCode, :firstEnteredDate, :enteredByUser, :lastAuditDate, :hardwarePrice, null)")
.setParameter("coxBarCode", coxBarcode)
.setParameter("serialNo", serialNo)
.setParameter("currentStatus", curstatus)
.setParameter("currentLocationNo", curloc)
.setParameter("desc", desc)
.setParameter("hardwareModelId", selmodid)
.setParameter("ownerTypeCode", selectedOwner)
.setParameter("firstEnteredDate", firstEnteredDate)
.setParameter("enteredByUser", enteredByUser)
.setParameter("lastAuditDate", lastAuditedDate)
.setParameter("hardwarePrice", unitPrice);
query.executeUpdate();
query = entityManager.createNativeQuery("INSERT INTO TbHardwareHistory "+
"VALUES (:hardwareId, :currentStatus, :currentLocationNo, :firstEnteredDate, null, :enteredByUser, :ownerTypeCode)")
.setParameter("hardwareId", findHardwareId(coxBarcode))
.setParameter("currentStatus", curstatus)
.setParameter("currentLocationNo", curloc)
.setParameter("firstEnteredDate", firstEnteredDate)
.setParameter("enteredByUser", enteredByUser)
.setParameter("ownerTypeCode", selectedOwner);
query.executeUpdate();
//TO DO: following query should return only one entity, need to refactor and remove the for loop below
TbHardware hw = (TbHardware)entityManager.createNativeQuery("SELECT t FROM tbHardware t WHERE t.coxBarCode = :coxBarCode AND t.serialNo = :serialNo", TbHardware.class)
.setParameter("coxBarCode", coxBarcode)
.setParameter("serialNo", serialNo)
.getSingleResult();
Integer hardwareId = hw.getHardwareId();
query = entityManager.createNativeQuery("INSERT INTO tbHardwareNote VALUES (:hardwareId, :hardwareNote)")
.setParameter("hardwareId", hardwareId).setParameter("hardwareNote", hardwareNote);
query.executeUpdate();
entityManager.flush();I am getting the following in the server.log:
10:10:57,552 ERROR [STDERR] Caused by: org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
10:10:57,552 ERROR [STDERR] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
10:10:57,552 ERROR [STDERR] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
10:10:57,552 ERROR [STDERR] at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:174)
10:10:57,552 ERROR [STDERR] at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
10:10:57,552 ERROR [STDERR] at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
10:10:57,552 ERROR [STDERR] at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:48)
10:10:57,552 ERROR [STDERR] ... 138 more
10:10:57,552 ERROR [STDERR] Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert duplicate key row in object 'dbo.tbHardware' with unique index 'IX_tbHardwar_coxBarCode_UNIQUE'.
10:10:57,552 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
10:10:57,552 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
10:10:57,552 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
10:10:57,552 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
10:10:57,552 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
10:10:57,552 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
10:10:57,552 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
10:10:57,552 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
10:10:57,552 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(Unknown Source)
10:10:57,552 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
10:10:57,552 ERROR [STDERR] at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:165)
10:10:57,552 ERROR [STDERR] ... 141 moreHow should I handle this SQLServerException? What is the best practice regarding this from a JPA perspective? I thought about executing a select query prior to the insert in tbHardware to check to see if a record with that particular coxBarCode exists or not. Would the exception be handled differently if I used the persist() method instead of the createNativeQuery() and executeUpdate() combination? thx.
Edited by: asookazian on May 7, 2008 11:07 AMkajbj wrote:
What do you mean by control? Yes, you can find duplicates and remove them (by e.g. implementing a Comparator and adding them to a Set)
KajI mean to say replace the duplication with just a single value for insert!
Any psuedo for the comparactor suggested? -
Sybase Error 2601 Attempt to insert duplicate key row in object with unique
RE: Sybase Error 2601 Attempt to insert duplicate key row in object with unique index.
Hi Folks,
I'm getting the following error whilst executing a stored procedure in Sybase.
ERROR: Sybase Error 2601 Attempt to insert duplicate key row in object with unique index.
I understand that duplicate values have been inserted into a column that has a unique constraint.
I just can't figure out how to rectify the problem.
Your help will be greatly appreciated!
Many thanks in advance.If the value I'm trying to insert (using update)
already exists in the unique-value field then the DB
refuses to update the field.
If the value is different it will update.Are you trying to insert or update in SQL (identified by the keyword INSERT or UPDATE respectively)?
Even in case of an UPDATE query, if you are going to update the values of some columns to violate the unique constraints, the update will not succeed and you will get the error message.
or is it?
it tries to create a new row, but can't because there
is another row with the same unique-values.
If this is the case, I am only trying to update and
not create a new item.To put it in simpler words, if you have a set of values defining the uniqueness of a record, you cannot insert another record with the same set of unique values. Similarly, you cannot update an existing record by modifying the set to conflict with another set of unique values which already exist in the database.
Suppose there are two columns A and B defining the uniqueness of the record and you have only two records at the moment like -
A B
========
1 1
2 1
If you try to insert a record with A = 1 and B = 1, it will fail because a record already exists. You cannot violate uniqueness because the database has already been told that there will be only one record for any given combination of A and B.
Similarly, if you try to update the second record from A = 2 to A = 1, the end result would be A =1 and B = 1. There is already a record with that set of values and this will result in a violation of the uniqueness. So, this update will also be disallowed. On the other hand, if you try to update B to some value, say 3, there is no problem in doing so.
For convenience, you can imagine an UPDATE operation to be equivalent to DELETE + INSERT operation, though it doesn't necessarily work the same way internally.
I hope I was clear enough.
Maybe you are looking for
-
How can i transfer all my photos from the iphone to be transferred to the PC
Hello there , Can anyone be of guide ? I have albums on the IPHONE 3Gs in the photo's category . How can I transfer all these to the Itunes or PC without selecting each one at a time & transferring to the email. Also the itunes i10 version does not s
-
Is enhancement to FI(AR, AP) cubes same as LO?
Hi, If I want to add more custom infoobjects to FI business content cubes, is the procedure same as writing routine in start routine and look up on the MD IO's, another way is enhancing the extract structures like we do to LO modules. My question is,
-
I'm using the two lines of code that I found in another Thread to get the system icon for a file and I'm using that icon in a JLabel. This is working and giving me the icons for most files, but so far there is one type of file I have found that this
-
Hi Guys, I require order by to be applied on both queries separatly. select a1,a2 from a union all select b1,b2 from b; in above scenerio, i want to sort query 1 by first column ie.a1 and query 2 by sencond column i.e. b2. Please suggest pointers on
-
Hi all, What do typical BW/BI teams look like? Is there a structure? How do most companies staff up. Additionally, is there a rule of thumb about staff size and number of daily loads, or active infoproviders? Thanks. Dave