HR_INFOTYPE_OPERATION in insert mode - duplicate records
Hi,
I'm using athe above function to insert a record into IT0015 (Additional Payments) i.e. Operational Mode is 'INS'
but when I have a record already in the system for the date specified it is just inserting a new record - is there a parameter I can pass into the function that will just update the record rather than creating a new one?
I know I can check prior to the operation via function 'HR_READ_INFOTYPE' if a record exists and then change the operational mode to 'MOD' before I call 'HR_INFOTYPE_OPERATION - is this the only way or can the HR_INFOTYPE_OPERATION handle this step.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0015'
number = p_pernr
subtype = p0015-subty
* OBJECTID =
* LOCKINDICATOR =
validityend = p0015-begda
validitybegin = p0015-begda
* RECORDNUMBER = 1 "RP 26.11.09
record = p0015
operation = p_operation
* TCLAS = 'A' "RP 26.11.09
* DIALOG_MODE = '0'
* NOCOMMIT =
* VIEW_IDENTIFIER =
* SECONDARY_RECORD =
IMPORTING
return = fs_return
* KEY =
Many thanks in advance.
Raj
Hello Volker,
Are you in anyway associated with Consulut IDES server? I remember seeing a similar name in it. Sorry if thats not you.
Vikranth
Similar Messages
-
Do we have a shortcut to insert a duplicate record except PK ?
Do we have a shortcut to insert a duplicate record except PK ?
Thanks.Do you want to insert another row with all of the columns the same but with a different PK? If so then:
INSERT INTO t (pk, col1, col2, col3)
SELECT new_value_for_pk, col1, col2, col3
FROM t
WHERE pk = <value>What you use for new_value_for_pk will depend on how the PK is generated.
John -
HR_INFOTYPE_OPERATION in insert mode
Hello
I'm having trouble using this function - the delete & update works ok but not the create what am I doing wrong?
FORM UPDATE_INFOTYPE USING VALUE(P_PERNR) VALUE(P_DATE) VALUE(P_SUBTYPE)
VALUE(P_AMOUNT) VALUE(P_OPERATION).
WRITE:/ 'Before Updation'.
LOOP AT P0015.
WRITE:/ P0015-PERNR,
P0015-BEGDA,
P0015-LGART,
P0015-BETRG.
ENDLOOP.
* Passing values to modify the infotype
P0015-PERNR = P_PERNR .
P0015-BEGDA = P_DATE.
P0015-LGART = P_SUBTYPE.
P0015-BETRG = p_amount.
*This function module enables you to maintain master data for employees and
*applicants. You can transfer one data record
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = '0015'
NUMBER = P_PERNR
SUBTYPE = P0015-SUBTY
* OBJECTID =
* LOCKINDICATOR =
VALIDITYEND = P0015-BEGDA
VALIDITYBEGIN = P0015-BEGDA
* RECORDNUMBER =
RECORD = P0015
OPERATION = P_OPERATION
* TCLAS = 'A'
* DIALOG_MODE = '0'
* NOCOMMIT =
* VIEW_IDENTIFIER =
* SECONDARY_RECORD =
IMPORTING
RETURN = FS_RETURN
* KEY =
REFRESH P0015.
CLEAR P0015.
ENDFORM. " READ_UPDATE_INFOTYPE
The return messeage I am geting for FS_RETURN is as follows:-
Enter a true account assignment relevant to cost accountingHi Raj,
<li>I tried the with the below code. It worked for me. Can you please check this way.
REPORT ztest_notepad .
DATA:p0015 TYPE p0015.
DATA:return LIKE bapireturn1.
p0015-pernr = '00909089'.
p0015-subty = '1500'.
p0015-endda = '99991231'.
p0015-begda = sy-datum.
p0015-lgart = '1500'.
p0015-betrg = '100.00'.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = '00909089'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0015'
number = '00909089'
subtype = '1500'
validityend = '99991231'
validitybegin = sy-datum
record = p0015
operation = 'INS'
tclas = 'A'
IMPORTING
return = return.
WRITE return.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = '00909089'.
Thanks
Venkat.O -
Purchase Order Import inserts duplicate records in po_line_locations
Hi,
I'm running standard Purchase Order Import program to import few PO's. We have only one shipment for each item, so its only one record for each line in po_line_locations. But after running the import, it inserts a duplicate record with same qty into po_line_locations. Basically it is inserting same item twice in po_line_locations_all table and quantity is getting doubles at the line level. Seached Metalink but no hits for this, till now.
This is in R12 (12.0.6).
Did anyone encounter this problem earlier? Any hints or comments would help.
Thanks in advance.
Edited by: user2343071 on Sep 2, 2009 3:54 PMHi,
Once you please debug the particular program with the help of ABAPer. That may resolve your issue. Thanking you -
Problem with duplicate records..
Hi..I am trying to insert the records to the database based on a button click from a Swing frame..I have succeeded in that...But when i try to insert a duplicate record it is showing com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 1
My code is
import java.awt.event.*;
import java.sql.*;
public class BarcodeReader extends javax.swing.JFrame implements ActionListener {
static Connection con;
static String url = "jdbc:mysql://localhost:3306/";
static String db = "mynewdatabase";
static String driver = "com.mysql.jdbc.Driver";
static String user = "uname";
static String pass = "pwd";
static Statement stmt;
/** Creates new form BarcodeReader */
public BarcodeReader() {
initComponents();
nb.addActionListener(this);
public static Connection getConnection(){
try{
Class.forName(driver);
con = DriverManager.getConnection(url + db, user, pass);
stmt=con.createStatement();
System.out.println("jdbc driver for mysql : " + driver);
System.out.println("Connection url : " + url + db);
}catch (Exception ex)
ex.printStackTrace();
return con;
private void ActionPerformed(java.awt.event.ActionEvent evt) {
Connection con=getConnection();
String t=newtxt.getText();
int t1=Integer.parseInt(t);
try{
PreparedStatement p=con.prepareStatement("INSERT INTO machine(barcode) values(?)");
ResultSet rs=stmt.executeQuery("SELECT * FROM MACHINE");
while(rs.next()){
String s=rs.getString("barcode");
if(s.equals(t))
System.out.println("this id exists....");
rs.last();
p.setInt(1, t1);
p.executeUpdate();
new NewJFrame().setVisible(true);
}catch(Exception e){
e.printStackTrace();
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new BarcodeReader().setVisible(true);
}When i insert a new record is ok, but when i am inserting the same record again it shows the following exception..
jdbc driver for mysql : com.mysql.jdbc.Driver
Connection url : jdbc:mysql://localhost:3306/mynewdatabase
this id exists....
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3536)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1957)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2107)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2086)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2371)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2289)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2274)
at project.BarcodeReader.ActionPerformed(BarcodeReader.java:276)
at project.BarcodeReader.access$000(BarcodeReader.java:17)
at project.BarcodeReader$1.actionPerformed(BarcodeReader.java:138)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)Thanks.shelton141 wrote:
Hi..I am trying to insert the records to the database based on a button click from a Swing frame..I have succeeded in that...But when i try to insert a duplicate record it is showing com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 1Of course it is. That is what it is suppossed to do.
Try inserting the same record twice, manually, and see what happens.
There is however, if I remember right, an "IGNORE" "clause/option/whatever" that you can use on INSERT statements in MySQL. Check the manual, if that is what you really want. -
Hi
We do have primary key in source table and key columns without constraint in target table. We do transformation of converting schema name in source while capturing.
We do allow_duplicate_rows=Y in apply side. Whenever, duplicate rows insert happening, it works fine. When it comes to update it not working it throws an error.
ORA-01422: exact fetch returns more than requested number of rows
ORA-01403: no data found
Could you please shed some light to fix this issue.?
Alternate solution, remove the duplicate and execute the streams error transaction, works fine. But allow_duplicate_rows functionality is not fulfilled.
Thanks
BalaSource 10.2.0.4.3
Target 10.2.0.3
We are creating the reporting instance, duplicate is allowed. Insert on duplicate records are successfully inserted, when it comes to update, it is failed with the following error.
----Error in Message: 1
----Error Number: 1422
----Message Text: ORA-01422: exact fetch returns more than requested number of rows
ORA-01403: no data found
--message: 1
type name: SYS.LCR$_ROW_RECORD
source database: PROD2
owner: REPORT_TWO
object: DEVICE
is tag null: Y
command_type: UPDATE
Supplemental logging is enabled for both source and target database.
Thanks
Bala -
Check for duplicate record in SQL database before doing INSERT
Hey guys,
This is part powershell app doing a SQL insert. BUt my question really relates to the SQL insert. I need to do a check of the database PRIOR to doing the insert to check for duplicate records and if it exists then that record needs
to be overwritten. I'm not sure how to accomplish this task. My back end is a SQL 2000 Server. I'm piping the data into my insert statement from a powershell FileSystemWatcher app. In my scenario here if the file dumped into a directory starts with I it gets
written to a SQL database otherwise it gets written to an Access Table. I know silly, but thats the environment im in. haha.
Any help is appreciated.
Thanks in Advance
Rich T.
#### DEFINE WATCH FOLDERS AND DEFAULT FILE EXTENSION TO WATCH FOR ####
$cofa_folder = '\\cpsfs001\Data_pvs\TestCofA'
$bulk_folder = '\\cpsfs001\PVS\Subsidiary\Nolwood\McWood\POD'
$filter = '*.tif'
$cofa = New-Object IO.FileSystemWatcher $cofa_folder, $filter -Property @{ IncludeSubdirectories = $false; EnableRaisingEvents= $true; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' }
$bulk = New-Object IO.FileSystemWatcher $bulk_folder, $filter -Property @{ IncludeSubdirectories = $false; EnableRaisingEvents= $true; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' }
#### CERTIFICATE OF ANALYSIS AND PACKAGE SHIPPER PROCESSING ####
Register-ObjectEvent $cofa Created -SourceIdentifier COFA/PACKAGE -Action {
$name = $Event.SourceEventArgs.Name
$changeType = $Event.SourceEventArgs.ChangeType
$timeStamp = $Event.TimeGenerated
#### CERTIFICATE OF ANALYSIS PROCESS BEGINS ####
$test=$name.StartsWith("I")
if ($test -eq $true) {
$pos = $name.IndexOf(".")
$left=$name.substring(0,$pos)
$pos = $left.IndexOf("L")
$tempItem=$left.substring(0,$pos)
$lot = $left.Substring($pos + 1)
$item=$tempItem.Substring(1)
Write-Host "in_item_key $item in_lot_key $lot imgfilename $name in_cofa_crtdt $timestamp" -fore green
Out-File -FilePath c:\OutputLogs\CofA.csv -Append -InputObject "in_item_key $item in_lot_key $lot imgfilename $name in_cofa_crtdt $timestamp"
start-sleep -s 5
$conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=PVSNTDB33; Initial Catalog=adagecopy_daily; Integrated Security=TRUE")
$conn.Open()
$insert_stmt = "INSERT INTO in_cofa_pvs (in_item_key, in_lot_key, imgfileName, in_cofa_crtdt) VALUES ('$item','$lot','$name','$timestamp')"
$cmd = $conn.CreateCommand()
$cmd.CommandText = $insert_stmt
$cmd.ExecuteNonQuery()
$conn.Close()
#### PACKAGE SHIPPER PROCESS BEGINS ####
elseif ($test -eq $false) {
$pos = $name.IndexOf(".")
$left=$name.substring(0,$pos)
$pos = $left.IndexOf("O")
$tempItem=$left.substring(0,$pos)
$order = $left.Substring($pos + 1)
$shipid=$tempItem.Substring(1)
Write-Host "so_hdr_key $order so_ship_key $shipid imgfilename $name in_cofa_crtdt $timestamp" -fore green
Out-File -FilePath c:\OutputLogs\PackageShipper.csv -Append -InputObject "so_hdr_key $order so_ship_key $shipid imgfilename $name in_cofa_crtdt $timestamp"
Rich ThompsonHi
Since SQL Server 2000 has been out of support, I recommend you to upgrade the SQL Server 2000 to a higher version, such as SQL Server 2005 or SQL Server 2008.
According to your description, you can try the following methods to check duplicate record in SQL Server.
1. You can use
RAISERROR to check the duplicate record, if exists then RAISERROR unless insert accordingly, code block is given below:
IF EXISTS (SELECT 1 FROM TableName AS t
WHERE t.Column1 = @ Column1
AND t.Column2 = @ Column2)
BEGIN
RAISERROR(‘Duplicate records’,18,1)
END
ELSE
BEGIN
INSERT INTO TableName (Column1, Column2, Column3)
SELECT @ Column1, @ Column2, @ Column3
END
2. Also you can create UNIQUE INDEX or UNIQUE CONSTRAINT on the column of a table, when you try to INSERT a value that conflicts with the INDEX/CONSTRAINT, an exception will be thrown.
Add the unique index:
CREATE UNIQUE INDEX Unique_Index_name ON TableName(ColumnName)
Add the unique constraint:
ALTER TABLE TableName
ADD CONSTRAINT Unique_Contraint_Name
UNIQUE (ColumnName)
Thanks
Lydia Zhang -
Data Loader inserting duplicate records
Hi,
There is an import that we need to run everyday in order to load data from another system into CRM On Demand . I have set up a data loader script which is scheduled to run every morning. The script should perform insert operation.
Every morning a file with new insert data is available in the same location(generated by someone else) & same name. The data loader script must insert all records in it.
One morning , there was a problem in the other job and a new file was not produced. When the data loader script ran , it found the old file and re-inserted the records (there were 3 in file). I had specified the -duplicatecheckoption parameter as the external id, since the records come from another system, but I came to know that the option works in the case of update operations only.
How can a situation like this handled in future? The external id should be checked for duplicates before the insert operation is performed. If we cant check on the data loader side, is it possible to somehow specify the field as 'unique' in the UI so that there is an error if a duplicate record is inserted? Please suggest.
Regards,Hi
You can use something like this:
cursor crs is select distinct deptno,dname,loc from dept.
Now you can insert all the records present in this cursor.
Assumption: You do not have duplicate entry in the dept table initially.
Cheers
Sudhir -
Avoiding duplicate records while inserting into the table
Hi
I tried the following insert statement , where i want to avoid the duplicate records while inserting itself
but giving me the errror like invalid identifier, though the column exists in the table
Please let me know Where i'm doing the mistake.
INSERT INTO t_map tm(sn_id,o_id,txt,typ,sn_time)
SELECT 100,
sk.obj_id,
sk.key_txt,
sk.obj_typ,
sysdate,
FROM S_KEY sk
WHERE sk.obj_typ = 'AY'
AND SYSDATE BETWEEN sk.start_date AND sk.end_date
AND sk.obj_id IN (100170,1001054)
and not exists (select 1
FROM t_map tm1 where tm1.O_ID=tm.o_id
and tm1.sn_id=tm.sn_id
and tm1.txt=tm.txt
and tm1.typ=tm.typ
and tm1.sn_time=tm.sn_time )Then
you have to join the table with alias tml where is that ?do you want like this?
INSERT INTO t_map tm(sn_id,o_id,txt,typ,sn_time)
SELECT 100,
sk.obj_id,
sk.key_txt,
sk.obj_typ,
sysdate,
FROM S_KEY sk
WHERE sk.obj_typ = 'AY'
AND SYSDATE BETWEEN sk.start_date AND sk.end_date
AND sk.obj_id IN (100170,1001054)
and not exists (select 1
FROM t_map tm where sk.obj_ID=tm.o_id
and 100=tm.sn_id
and sk.key_txt=tm.txt
and sk.obj_typ=tm.typ
and sysdate=tm.sn_time ) -
The ABAP/4 Open SQL array insert results in duplicate Record in database
Hi All,
I am trying to transfer 4 plants from R/3 to APO. The IM contains only these 4 plants. However a queue gets generated in APO saying 'The ABAP/4 Open SQL array insert results in duplicate record in database'. I checked for table /SAPAPO/LOC, /SAPAPO/LOCMAP & /SAPAPO/LOCT for duplicate entry but the entry is not found.
Can anybody guide me how to resolve this issue?
Thanks in advance
Sandeep PatilHi Sandeep,
Now try to delete ur location before activating the IM again.
Use the program /SAPAPO/DELETE_LOCATIONS to delete locations.
Note :
1. Set the deletion flag (in /SAPAPO/LOC : Location -> Deletion Flag)
2. Remove all the dependencies (like transportation lane, Model ........ )
Check now and let me know.
Regards,
Siva.
null -
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. -
To insert duplicate records in VO
Hi,
I have a button Duplicate Record on page.
All the existing details on the page are read only except a checkbox for all rows.
When i select the checkbox and click on 'duplicate Record' button, an editable row with the same data as the selected checkbox row should be created on page. This row is getting created but the issue is that the row from which it has been dupliacted also becomes editable. And the changes made to new row gets reflected in Old Row as well.
Any solutions to have the old row read only and only new row as editable?ok..what i understand is as follows..
In the VO, i create a transient variable 'RowRef' and select it in my VO query.
In my results table, i create a form value "evtSrcRowRef" with View attribute as 'RowRef'.
In CO, i write,
String rowReference = pageContext.getParameter("evtSrcRowRef");
Please correct me if i am wrong or missing somethimg..also please detail how do i use this row refernce to make my original row read only.. -
Dear All,
I have oracle 10g R2 On windows.
I have table structure like below...
ASSIGNED_TO
USER_ZONE
CREATED
MASTER_FOLIO_NUMBER
NAME
A_B_BROKER_CODE
INTERACTION_ID
INTERACTION_CREATED
INTERACTION_STATE
USER_TEAM_BRANCH
A4_IN_CALL_TYPE
A5_IN_CALL_SUBTYPE
DNT_AGING_IN_DAYS
DNT_PENDING_WITH
DNT_ESCALATION_STAGE_2
DT_UPDATEI use sql loader to load the data from .csv file to oracle table and have assign the value to dt_update sysdate. Everytime i execute the sql loader control file dt_update set as sysdate.
Sometimes problem occures while inserting data through sql loader and half row get insert. after solving the problem again i execute sql loader and hence these duplicate records get inserted.
Now I want to remove all the duplicate records for those dt_update is same.
Please help me to solve the problem
Regards,
Chanchal Wankhade.Galbarad wrote:
Hi
I think you have two ways
first - if it is first import in your table - you can delete all record from table and run import yet one time
second - you can delete all duplicate records and not running import
try this script
<pre>
delete from YOUR_TABLE
where rowid in (select min(rowid)
from YOUR_TABLE
group by ASSIGNED_TO,
USER_ZONE,
CREATED,
MASTER_FOLIO_NUMBER,
NAME,
A_B_BROKER_CODE,
INTERACTION_ID,
INTERACTION_CREATED,
INTERACTION_STATE,
USER_TEAM_BRANCH,
A4_IN_CALL_TYPE,
A5_IN_CALL_SUBTYPE,
DNT_AGING_IN_DAYS,
DNT_PENDING_WITH,
DNT_ESCALATION_STAGE_2,
DT_UPDATE)
</pre>Have you ever tried that script for deleting duplicates? I think not. If you did you'd find it deleted non-duplicates too. You'd also find that it only deletes the first duplicate where there are duplicates.
XXXX> CREATE TABLE dt_test_dup
2 AS
3 SELECT
4 mod(rownum,3) id
5 FROM
6 dual
7 CONNECT BY
8 level <= 9
9 UNION ALL
10 SELECT
11 rownum + 3 id
12 FROM
13 dual
14 CONNECT BY
15 level <= 3
16 /
Table created.
Elapsed: 00:00:00.10
XXXX> select * from dt_test_dup;
ID
1
2
0
1
2
0
1
2
0
4
5
6
12 rows selected.
Elapsed: 00:00:00.18
XXXX> delete
2 from
3 dt_test_dup
4 where
5 rowid IN ( SELECT
6 MIN(rowid)
7 FROM
8 dt_test_dup
9 GROUP BY
10 id
11 )
12 /
6 rows deleted.
Elapsed: 00:00:00.51
XXXX> select * from dt_test_dup;
ID
1
2
0
1
2
0
6 rows selected.
Elapsed: 00:00:00.00 -
Prevent duplicate records?
hi
can any one tell me
how can i prevent the user from typing duplicate records into a tabular form? which trigger should i use?and how to do that?
and also how to restrict inserting duplicate records into my table throw a code which will be in my form.Kevin in his post said
>>
Although you cannot normally read other records in a multi row block without navigating to them, I have found a cunning method to do this validation using the power of calculation properties. You need three extra hidden fields, two of which have calculation properties, and a little function. (If you want to see how it works, try making the hidden fields visible).
Form program unit:
function COMPARISON (in1 number, in2 number) is
if in1 = in2 then
return(1);
else
return(0);
end if;
end;
3 new hidden fields:
CONTROL.PK_COPY
DATABLOCK.MATCH_FOUND
calculation mode: formula
formula: COMPARISON(:control.PK_COPY, :datablock.PK)
CONTROL.NUMBER_OF_MATCHES
calculation_mode: summary
summary_function: Sum
summarised_block: DATABLOCK
summarised_item: MATCH_FOUND
WHEN_VALIDATE_ITEM on DATABLOCK.PK
:control.pk_copy := :datablock.pk;
if :control.number_of_matches > 1 then
message('matching key found');
end if;
(DATABLOCK must have query_all_records = TRUE)
<<
what do i have to name my fields and what to do in each field?
becuase i got lost in what Kevin said.
please answer me! -
How to find out duplicate record contained in a flat file
Hi Experts,
For my project I have written a program for flat file upload.
Requirement 1
In the flat file there may be some duplicate record like:
Field1 Field2
11 test1
11 test2
12 test3
13 test4
Field1 is primary key.
Can you please let me know how I can find out the duplicate record.
Requirement 2
The flat file contains the header row as shown above
Field1 Field2
How our program can skip this record and start reading / inserting records from row no 2 ie
11 test1
onwards.
Thanks
S
FORM upload1.
DATA : wf_title TYPE string,
lt_filetab TYPE filetable,
l_separator TYPE char01,
l_action TYPE i,
l_count TYPE i,
ls_filetab TYPE file_table,
wf_delemt TYPE rollname,
wa_fieldcat TYPE lvc_s_fcat,
tb_fieldcat TYPE lvc_t_fcat,
rows_read TYPE i,
p_error TYPE char01,
l_file TYPE string.
DATA: wf_object(30) TYPE c,
wf_tablnm TYPE rsdchkview.
wf_object = 'myprogram'.
DATA i TYPE i.
DATA:
lr_mdmt TYPE REF TO cl_rsdmd_mdmt,
lr_mdmtr TYPE REF TO cl_rsdmd_mdmtr,
lt_idocstate TYPE rsarr_t_idocstate,
lv_subrc TYPE sysubrc.
TYPES : BEGIN OF test_struc,
/bic/myprogram TYPE /bic/oimyprogram,
txtmd TYPE rstxtmd,
END OF test_struc.
DATA : tb_assum TYPE TABLE OF /bic/pmyprogram.
DATA: wa_ztext TYPE /bic/tmyprogram,
myprogram_temp TYPE ziott_assum,
wa_myprogram TYPE /bic/pmyprogram.
DATA : test_upload TYPE STANDARD TABLE OF test_struc,
wa2 TYPE test_struc.
DATA : wa_test_upload TYPE test_struc,
ztable_data TYPE TABLE OF /bic/pmyprogram,
ztable_text TYPE TABLE OF /bic/tmyprogram,
wa_upld_text TYPE /bic/tmyprogram,
wa_upld_data TYPE /bic/pmyprogram,
t_assum TYPE ziott_assum.
DATA : wa1 LIKE test_upload.
wf_title = text-026.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = wf_title
default_extension = 'txt'
file_filter = 'Tab delimited Text Files (*.txt)'
CHANGING
file_table = lt_filetab
rc = l_count
user_action = l_action
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
OTHERS = 3. "#EC NOTEXT
IF sy-subrc 0.
EXIT.
ENDIF.
LOOP AT lt_filetab INTO ls_filetab.
l_file = ls_filetab.
ENDLOOP.
CHECK l_action = 0.
IF l_file IS INITIAL.
EXIT.
ENDIF.
l_separator = 'X'.
wa_fieldcat-fieldname = 'test'.
wa_fieldcat-dd_roll = wf_delemt.
APPEND wa_fieldcat TO tb_fieldcat.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
CLEAR wa_test_upload.
Upload file from front-end (PC)
File format is tab-delimited ASCII
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
has_field_separator = l_separator
TABLES
data_tab = i_mara
data_tab = test_upload
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc 0.
EXIT.
ELSE.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
IF test_upload IS NOT INITIAL.
DESCRIBE TABLE test_upload LINES rows_read.
CLEAR : wa_test_upload,wa_upld_data.
LOOP AT test_upload INTO wa_test_upload.
CLEAR : p_error.
rows_read = sy-tabix.
IF wa_test_upload-/bic/myprogram IS INITIAL.
p_error = 'X'.
MESSAGE s153 WITH wa_test_upload-/bic/myprogram sy-tabix.
CONTINUE.
ELSE.
TRANSLATE wa_test_upload-/bic/myprogram TO UPPER CASE.
wa_upld_text-txtmd = wa_test_upload-txtmd.
wa_upld_text-txtsh = wa_test_upload-txtmd.
wa_upld_text-langu = sy-langu.
wa_upld_data-chrt_accts = 'xyz1'.
wa_upld_data-co_area = '12'.
wa_upld_data-/bic/zxyzbcsg = 'Iy'.
wa_upld_data-objvers = 'A'.
wa_upld_data-changed = 'I'.
wa_upld_data-/bic/zass_mdl = 'rrr'.
wa_upld_data-/bic/zass_typ = 'I'.
wa_upld_data-/bic/zdriver = 'yyy'.
wa_upld_text-langu = sy-langu.
MOVE-CORRESPONDING wa_test_upload TO wa_upld_data.
MOVE-CORRESPONDING wa_test_upload TO wa_upld_text.
APPEND wa_upld_data TO ztable_data.
APPEND wa_upld_text TO ztable_text.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM ztable_data.
DELETE ADJACENT DUPLICATES FROM ztable_text.
IF ztable_data IS NOT INITIAL.
CALL METHOD cl_rsdmd_mdmt=>factory
EXPORTING
i_chabasnm = 'myprogram'
IMPORTING
e_r_mdmt = lr_mdmt
EXCEPTIONS
invalid_iobjnm = 1
OTHERS = 2.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
**Lock the Infoobject to update
CALL FUNCTION 'RSDG_IOBJ_ENQUEUE'
EXPORTING
i_objnm = wf_object
i_scope = '1'
i_msgty = rs_c_error
EXCEPTIONS
foreign_lock = 1
sys_failure = 2.
IF sy-subrc = 1.
MESSAGE i107(zddd_rr) WITH wf_object sy-msgv2.
EXIT.
ELSEIF sy-subrc = 2.
MESSAGE i108(zddd_rr) WITH wf_object.
EXIT.
ENDIF.
*****Update Master Table
IF ztable_data IS NOT INITIAL.
CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
EXPORTING
i_iobjnm = 'myprogram'
i_tabclass = 'M'
I_T_ATTR = lt_attr
TABLES
i_t_table = ztable_data
EXCEPTIONS
attribute_name_error = 1
iobj_not_found = 2
generate_program_error = 3
OTHERS = 4.
IF sy-subrc 0.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'zddd_rr'
msgty = 'E'
txtnr = '054'
msgv1 = text-033
EXCEPTIONS
OTHERS = 3.
MESSAGE e054(zddd_rr) WITH 'myprogram'.
ELSE.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'zddd_rr'
msgty = 'S'
txtnr = '053'
msgv1 = text-033
EXCEPTIONS
OTHERS = 3.
ENDIF.
*endif.
*****update Text Table
IF ztable_text IS NOT INITIAL.
CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
EXPORTING
i_iobjnm = 'myprogram'
i_tabclass = 'T'
TABLES
i_t_table = ztable_text
EXCEPTIONS
attribute_name_error = 1
iobj_not_found = 2
generate_program_error = 3
OTHERS = 4.
IF sy-subrc 0.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'zddd_rr'
msgty = 'E'
txtnr = '055'
msgv1 = text-033
EXCEPTIONS
OTHERS = 3.
ENDIF.
ENDIF.
ELSE.
MESSAGE s178(zddd_rr).
ENDIF.
ENDIF.
COMMIT WORK.
CALL FUNCTION 'RSD_CHKTAB_GET_FOR_CHA_BAS'
EXPORTING
i_chabasnm = 'myprogram'
IMPORTING
e_chktab = wf_tablnm
EXCEPTIONS
name_error = 1.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
****Release locks on Infoobject
CALL FUNCTION 'RSDG_IOBJ_DEQUEUE'
EXPORTING
i_objnm = 'myprogram'
i_scope = '1'.
ENDIF.
ENDIF.
PERFORM data_selection .
PERFORM update_alv_grid_display.
CALL FUNCTION 'MESSAGES_SHOW'.
ENDFORM.Can you please let me know how I can find out the duplicate record.
you need to split the records from flat file structure into your internal table ans use a delete ADJACENT duplicates comparing fields
split flat_str into wa_f1 wa_f2 wa_f2 at tab_space.
Maybe you are looking for
-
What is the best way to create a database schema from XML
What is the best way to create a database schema from XML? i have a complex XML file that I want to create a database from and consistently import new XML files of the same schema type. Currently I have started off by mapping the XSD into Excel and
-
Configuration Wizard failed at 8th step after installing sp3 patching in Moss 2007
Hi While running in the config wizard it failed at 8th step please give me some suggestion on this [SPManager] [ERROR] [2/9/2014 8:18:52 AM]: ReflexiveUpgrade [SPServer Name=***** Parent=SPFarm Name=SharePoint_Config] failed. ] [ERROR] [2/9/2014 8:18
-
Using array as a dataprovider for combobox
Hi folks, I would apreciate some help. I have a multi dimentional array as per _dbNames[0]=["Initialize User","","",""]; How can assign an array like this as a dataprovider to a combobox using actionscript 3? Thanks for for the help!!
-
Flash player crashes all my browsers
Hi, The problem appears on a new and clean XP SP3 (or SP2) installation. I changed my graphic card last week, no effects... There is a virus or something causing this kind of crashs? Maybe a trojan on my External hard drive, but nothing found after a
-
This is probably a relatively easy question as long as I explain it well enough: I have two tables: categorycodes and properties categorycodes is a lookup table. both tables have a field catcode that is a char(1) that contains matching data (only num