Check duplicates

Hi,
How would I check duplicate records in an internal table?
Thanks
Will

Hi this si the code which can give u the list of the Key field of the records which are having more than one records, prerequestisite is tht "u shud have atleast a primary key in ur internal table"..please change the code as per ur requrimetn ,it wil work and efficient too ,if number of records is too large in table -
Data : begin of itab occurs 0,
       pernr like pernr-pernr,
       endda like p0001-endda,
       end of itab.
Data : begin of pernr_list occurs 0,
       pernr like pernr-pernr,
       end of pernr_list.
data : itab1 type range of itab WITH HEADER LINE,
       itab2 like standard table of itab with header line.
DATA: DUPCOUNT TYPE I,
      ORICOUNT TYPE I,
      NEWCOUNT TYPE I,
      TOTALHIT TYPE I VALUE 0.
Start-of-selection.
select pernr endda into corresponding fields of table itab
from pa0001
where endda = '99991231' and persg = p_eg and
pernr in ( select pernr from pa0000 where STAT2 = p_es
           and endda = '99991231' ).
if sy-subrc = 0.
sort itab by pernr.
itab2[] = itab[].
DESCRIBE TABLE ITAB LINES ORICOUNT.
DELETE ADJACENT DUPLICATES FROM ITAB2.
DESCRIBE TABLE ITAB2 LINES NEWCOUNT.
DUPCOUNT = ORICOUNT - NEWCOUNT.
  ITAB1-SIGN   =  'I'.
  ITAB1-OPTION   =  'EQ'.
  ITAB1-LOW  = '00000000'.
  APPEND ITAB1.
loop at itab.
IF NOT ITAB-PERNR IN ITAB1.
  ITAB1-SIGN   =  'I'.
  ITAB1-OPTION   =  'EQ'.
  ITAB1-LOW  = ITAB-PERNR.
  APPEND ITAB1.
ELSE.
  pernr_list-pernr = itab-pernr.    "Contain key field Pernr of duplicate records
  append pernr_list.
  TOTALHIT = TOTALHIT + 1.
  IF DUPCOUNT EQ TOTALHIT.
   EXIT.
  ENDIF.
ENDIF.
endloop.
Reward points if helpfull..

Similar Messages

  • Check Duplicate invoice

    Hi everyone,
    Generally the system currently uses the keys to check for duplicate invoice in FB60 ( vendor number, invoice date, invoice number and invoice amount. MIRO only checks for three keys (vendor number, invoice number, and invoice date).
    Is there anyway where i can change the config for the MIRO to also check the invoice amount.
    Thanks in advance
    Genie

    Hi
    In FI module,for checking duplicate invoice is differ with MM module.When you ticked the flag for refence no. in Tcode OMRDC,system will not check the amount in MM.Otherwise,system will check it.
    Only the Company code, Document date, and Reference fields are configurable in transaction OMRDC  If none are checked, then the system only looks at the Currency, Vendor,and Amount.
    Please also read the following online documentation,
    If you activate the reference document number in IMG,
    Depending on the reference document number entry,the system checks
    as follows:
    1.If you have entered a reference document number,the system checks
    whether the invoice matches in the following attributes:
       Company code                       *
       Vendor                                  *
       Currency                               *        >no amount check.
       Invoice date                           *
       Reference document number   *
    2. If you have "not" entered a reference document number, the system
    checks whether the invoice matches in the following attributes:
       Company code                       *
       Vendor                                   *
       Currency                                *
       Invoice date                            *
       Amount in document currency  <         *!!!
    Depending on the system settings, a warning message or an error message appears if the system finds an invoice that matches all attributes.
    Please also keep in mind:The field Chk double inv(Check for duplicate invoice) must be flagged on the Accounting view in the vendor master record.
    I hope it useful.
    Regards
    Ravinagh Boni
    Rewards me If it useful.

  • Check Duplicate Invoice in FB60 and F-43

    Dear Experts,
    I want to check duplicate invoice in FB60 and F-43. Normally, system only check if company code, vendor, currency, reference no. and invoice date are match. If I only want to check for company code, vendor, currency, reference no. are match except invoice date.
    Anybody can help?

    Unfortunately, standard SAP only allows a fixed duplicate invoice check in F-43/FB60.  Unlike LIV, you cannot configure which fields get checked.
    Use BTE 00001110 (process module) and build a function that reads the MM LIV duplicate invoice configuration (table t169p).  The BTE will be called appropriately for F-43/FB60.  I developed and implemented this a while ago and it works great.
    I hope this is useful.

  • How to include a new field for checking duplicate customer master

    Dear All
    we have activated the standard procedure to check duplicate customer master data. This is a standard procedure as below :-
    Procedure:
    Run SM30, key in Table V_T100C, select Display or Maintain, set App area F2. Here you can change current settings.
    Check the transaction OBMSG for application area F2, where these messages are maintained and at this place you can convert the message from warning to error.e user needs one more field to be added to this check.
    It is working perfectly fine but it only compares two fields for duplicates in the customer master i.e the customer city and name.
    Is there a way to include a new field in this procedure ? For example we also want the system to check duplicate entries for field name " street 5" and give a warning /error message incase if there is another entry already existing on the master data.
    regards,

    Hi
    Use the enhancement SAPMF02D to check these values.
    Regards
    Eduardo

  • Check duplicate data entry in multi record block,which is a mandatory field

    Dear all,
    I have a situation where i have to check duplicate data entry(on a particular field,which is a mandatory field,i.e. it cannot be skipped by user without entering value) while data key-in in a Multi Record block.
    As for reference I have used a logic,such as
    1>In a When-Validate-Record trigger of that block I am assigning the value of that current item in Table type variable(collection type)
    as this trigger fire every time as soon as i leave that record,so its assigning the value of that current time.And this process continues
    then
    2>In a When-Validate-Item trigger of that corresponding item(i.e. the trigger is at item level) has been written,where it compares the value of that current item and the value stored in Table type variable(collection type) of When-Validate-Record trigger.If the current item value is matched with any value stored in Table type variable I am showing a message of ('Duplicate Record') following by raise_form_trigger failure
    This code is working fine for checking duplicate value of that multi record field
    The problem is that,if user enter the value in that field,and then goes to next field,enter value to that field and then press 'Enter Query 'icon,the bolth Validate trigger fires.As result first when-validate record fires,which stores that value,and then when-validate-item fires,as a result it shows duplicate record message
    Please give me a meaningful logic or code for solving this problem
    Any other logic to solve this problem is also welcome

    @Ammad Ahmed
    first of all thanks .your logic worked,but still i have some little bit of problem,
    now the requirement is a master detail form where both master and detail is multirecord ,where detail cannot have duplicate record,
    such as..........
    MASTER:--
    A code
    A1
    A2
    DETAIL:--
    D code
    d1
    d2 <-valid as for master A1 , detail d1 ,d2 are not duplicate
    d2 <--invalid as as for master A1 , detail d2 ,d2 are duplicate
    validation rule:  A Code –D Code combination is unique. The system will stop users from entering duplicate D Code for a A Code. Appropriate error message will be displayed.*
    actually i am facing a typical problem,the same logic i have been applied in detail section ,its working fine when i am inserting new records.problem starts when i query,after query in ' a ' field say 2 records (i.e. which has been earlier saved) has been pasted,now if i insert a new record with the value exactly same with the already present value in the screen(i.e. value populated after query) its not showing duplicate.................could u tell me the reason?and help me out...............its urgent plzzzzzzzzz
    Edited by: sushovan on Nov 22, 2010 4:34 AM
    Edited by: sushovan on Nov 22, 2010 4:36 AM
    Edited by: sushovan on Nov 22, 2010 8:58 AM

  • Check Duplicate data during data key-in Multi Record Block

    Dear all,
    I have a situation where i have to check duplicate data entry(on a particular field,which is a mandatory field,i.e. it cannot be skipped by user without entering value) while data key-in in a Multi Record block.
    As for reference I have used a logic,such as
    1>In a When-Validate-Record trigger of that block I am assigning the value of that current item in Table type variable(collection type)
    as this trigger fire every time as soon as i leave that record,so its assigning the value of that current time.And this process continues
    then
    2>In a When-Validate-Item trigger of that corresponding item(i.e. the trigger is at item level) has been written,where it compares the value of that current item and the value stored in Table type variable(collection type) of When-Validate-Record trigger.If the current item value is matched with any value stored in Table type variable I am showing a message of ('Duplicate Record') following by raise_form_trigger failure
    This code is working fine for checking duplicate value of that multi record field
    The problem here is that suppose if usee gets a message of ('Duplicate Record') and after that without saving the values if user try to query of that block then also when validate item fired where as I am expecting ORACLE default alert message('Do You want to save?'),I want to restrict this When-Validate Item fire during query time..........................while user try to query.
    Please give me a meaningful logic or code for solving this problem
    Any other logic to solve this problem is also welcome

    When-Validate-Record trigger
    When-Validate-Item triggerThat smells like Oracle Forms...
    And the Oracle Forms forum is over here: Forms

  • Check duplicate asset number during MIGO

    Hi MM/Abap Gurus ,
    What user exit can be used to check duplicate asset number during GR. E.g: I have a PO with same asset number for item line 1 and 2. What user exit can be used to set warning msg if duplicate asset number exits during MIGO. Please advise if there any user exit can be used for my requirement?
    Thanks
    Mitra

    Hi Puspha,
    Actually, the scenarios as below:
    1. PO created with 1 line item with Acc Assign Cat = A and multiple account assignment. Therefore, under the account assignment tab there are duplicate asset number inputted.
    2. Hence, when do GR, the system should prompt warning message " Duplicate asset number exists".
    Above are the requirement. I need any user exit that I can use in MIGO, where there is checking on duplicate asset number or during the sving of MIGO, I could inforce a logic on the checking.
    Your help appreciated.
    Thanks

  • Check duplicate record in array

    suppose i have an array
    int a[]={1,2,3,4,4,5,6,7,7};
    how should i check duplicate record and remove them?
    thanks...

    Write yourself some pseudo-code:
    // Loop though all the elements in the array from 0 to length-2.
    // For each element i, loop through following elements from i+1 to length-1
    // if the following element is equal to the current one, do something with it.
    "do something" can mean either one of two things:
    (1) Remove it (VERY messy) or
    (2) Create a new array and only add in the non-duplicate elements.
    The easiest thing of all would be to create a List and then create a Set from that. Why code all this logic when somebody has already done it for you? Look at the java.util.Arrays and java.util.Collections classes. Use what's been given to you.
    %

  • How to check duplicate in a very large table

    How  to  check duplicate  value (say mobile number) in a table  having 50 million records

    I need  to  know whether  the data(Mobile Number)  is  already  there  in  the  table whenever a new  row  is  inserted
    You can also use the MERGE statement and the WHEN NOT MATCHED clause to insert rows only if that value is not there.
    But if you are just checking the one column then a unique index would do it.
    Does that column allow a NULL value?
    Do you care about existing duplicate values?
    If you only want to check NEW inserts then create a UNIQUE constraint and use the ENABLE NOVALIDATE clause:
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/clauses002.htm
      ENABLE NOVALIDATE ensures that all new DML operations on the constrained data comply with the constraint. This clause does not ensure that existing data in the table complies with the constraint.
    That will check new data but leave the old data alone - no performance hit for the old data.

  • How to check duplicate entries in internal table??

    Dear Friends,
    How to check duplicate entries in internal table??
    Exp: In my internal table if I am having the same records more then ones then I need to print the error message, here I am using steploop for selecting the values from screen, and the values are coming into my internal table if user enter the same value more then ones I need to print the error message.
    Thanks,
    Sridhar

    Hi,
    After storing the data into internal table say ITAb, move the data into another internal table.
    t_dup[] = itab[].
    LOOP AT itab.
        count1 = count1 + 1.
        itab-count1 = count1.
        MODIFY itab.
    ENDLOOP.
    LOOP AT t_dup.
        count2 = count2 + 1.
        t_dup-count2 = count2.
        MODIFY t_dup.
    ENDLOOP.
      DELETE ADJACENT DUPLICATES FROM itab.
      LOOP AT t_dup.
        record_dup = 'N'.
        READ TABLE itab WITH KEY count1 = t_dup-count2.
        IF sy-subrc = 0.
          record_dup = 'Y'.
        ENDIF.
        IF record_dup NE 'Y'.
          t_dup-message = 'DUPLICATE ENTRY'.
          t_dup-flag = 1.
          MODIFY t_dup.
        ENDIF.
      ENDLOOP.
    Use this sample code.
    Reward pts if it is helpfull.
    Regards
    Srimanta

  • Check Duplicates on the Contract Business Partner

    Hi:
    I would like to know how does the configuration work in public sector for Check for Duplicates on Contract Partner Business Partner or is there a SAP document that explain in depth this functionality??
    Regards.

    Hi, You can activate through customization " Activate Duplicate Cleansing" for BP's. Choose Object BUPA for this anf Type D.
    For CA Define Contract Account/Business Partner Relationships. To check Duplicate CA's i think you will have to modify the FM and also add in a customised field in table FKKVK and then make changes toBAPI_CTRACDOCUMENT_CREATE to validate before creating the CA. its a bit complex, but your abaper will be able to do it. I hope this helps.
    Rgds
    Saj

  • Checking duplicate description material

    Hi,
    Please help me to do checking duplicate description material when create material in MM01. It is possible or not. What setting i can do in the system.
    Thank you.

    Hi,
    Check with Enhancement: MGA00001, User exit: EXIT_SAPLMGMU_001 for control.
    Also can be checked BADI_MATERIAL_CHECK
    Have concept of  new material creation with  validation & do  ABAP works necessary.
    More check link:
    Material Master
    Regards,
    Biju K

  • Checking Duplicate entry using session

    I have a CF 7 MX form with many form variables and would like
    to check duplicate data entry (into Access 2003) using the session
    id. The below shows my form action page and would like to know if
    this looks okay:

    I have a CF 7 MX form with many form variables and would like
    to check duplicate data entry (into Access 2003) using the session
    id. The below shows my form action page and would like to know if
    this looks okay:

  • Customize Alert messages for checking duplicate value and Success alert

    Hi All,
    I want to show two alert against the same "Submit" button to--
    1. Alert messages for checking duplicate value and show the Duplicate value found alert and
    2. Success Alert if the form is success to commit and no duplicate value found.
    I did all thing but when alert-1 shows and i pressed the ok button of the alert then the second alert also shows which i don't want to show.
    Which i can do in this issue? Have there anyone to help me!
    Arif

    Hi Manu,
    I have placed the following code
    1. against the Submit button--
    if error_code=40508 then
         commit_form;
    elsif :USERDELETION.CANCELLATION_USERID is not null then
    do_key('COMMIT_FORM');
    else null;
    end if;
    2. Code against the key-commit trigger in the form level--
    commit_form;
    DECLARE
    vAlert NUMBER;
    BEGIN
    set_alert_property('ALERT_TO_VERIFY',ALERT_MESSAGE_TEXT, 'Your Form has successfully submitted and your Reference id is '||:USERDELETION.REF_NO);
    vAlert:=SHOW_ALERT('ALERT_TO_VERIFY');
    END;
    3. Code against the on-error trigger in the form level--
    DECLARE
    vAlert NUMBER;
    BEGIN
         if ERROR_CODE = 40508 then
    set_alert_property('ERROR_ALERT',ALERT_MESSAGE_TEXT, 'This user deletion request has already submitted of the user named '||'"'||:USERDELETION.FULLNAME||'"');
    vAlert:=SHOW_ALERT('ERROR_ALERT');
    elsif
              ERROR_CODE = 40202 then
    set_alert_property('ERROR_ALERT',ALERT_MESSAGE_TEXT, 'Existing userid must be filled-up !');
    vAlert:=SHOW_ALERT('ERROR_ALERT');
    else
                   message(error_type||to_char(error_text)||': '||error_text);
    end if;
    END;
    If there have any confusion, please ask me.
    Arif

  • Validation Check - Duplicate vendor Invoices

    Hi,
    We have a situation where the Duplicate Vendor Invoices have been entered by the users, bearing the same date and reference nos. as the original ones. When we checked we observed that, the system gives the warning message, but the same is ignored by the users. To prevent the same from happening again, we want to convert the warning message into the error message.
    Could any one guide as to how can we set up the validation checks, such that the system would throw an error message. In the vendor masters, we have set up the check for Duplicate Invoices.
    Thanks in advance.
    Best Regards,

    Hi,
    If you already know the message number, then go to T.code:OBA5 or
    T.code:SE91 (if its an custom message class) and change the message from waring to Error.
    If you are not aware of Message, and try to post a duplicate invoice & when the warning message comes, double click on the same, it will give you the message number.
    This will resolve your issue.
    Please let me know the result of the same
    Thanks
    Kalyan

Maybe you are looking for

  • External Hard Drive won't turn on

    Hi all, I have just bought a brand new iMac and a new Western Digital 1TB External Hard Drive to use Time Machine on. I have plugged it all in, done my first back up and it all went fine. Then, I turned off my computer and all the plugs to go to bed

  • No way to definitely delete an iphone app in itunes tab

    I have a very long list of unused app in the left column of the app itunes tab... And no way to delete them. I have looked everywhere in the web, some people say that, when deleting an app, there should be a pop-up window asking me if a want to only

  • Can I play Blu Ray on MacBookPro 2.4Ghz intel 2 core Duo

    Hi, Just wanted to know if my MacBookPro 2.4Ghz intel 2 core Duo can play Blu Ray DVD

  • G5 start disk error

    My G5 has been acting a bit odd lately. it started with me noticing it was running slow. I realized I was filling up the hard drive so I purchased an external and removed about half of the material on the hard drive. THen I noticed it didn't matter i

  • RFCLIB access from Perl / Java  - newbie question

    Hi folks, I am newbie with SAP. I am triying to access the SAP from my web application, wrote in PErl or JAva. I am trying to access the librfc, bit I would like to know: 1) What software I need to install in my client side (the web server that host