ITAB - look for duplicates

I want to do something like this....
Let's say my ITAB has MATNR & DUP fields & let's say ITAB has entries like this...
ITAB-MATNR      ITAB-DUP
123
123
345
456
if any of the MATNR's are repeated in ITAB I want to flag DUP for such repeated records so the ITAB would look like below......
ITAB-MATNR      ITAB-DUP
123
123                    X
345
456
Please note : only the records repeated after the first unique record should be flagged.

Try this
REPORT  zrich_0001.
TYPE-POOLS: abap.
TYPES: BEGIN OF ttab,
        matnr(18) TYPE c,
        dup TYPE abap_bool,
       END OF ttab.
DATA: itab TYPE TABLE OF ttab.
DATA: wa LIKE LINE OF itab.
DATA: itab_copy TYPE TABLE OF ttab.
DATA: wa_copy LIKE LINE OF itab_copy.
DATA: tabix TYPE i.
wa-matnr = '000000000000000123'.  APPEND wa TO itab.
wa-matnr = '000000000000000123'.  APPEND wa TO itab.
wa-matnr = '000000000000000123'.  APPEND wa TO itab.
wa-matnr = '000000000000000345'.  APPEND wa TO itab.
wa-matnr = '000000000000000456'.  APPEND wa TO itab.
wa-matnr = '000000000000000456'.  APPEND wa TO itab.
itab_copy = itab.
LOOP AT itab_copy INTO wa_copy.
  tabix = sy-tabix + 1.
  LOOP AT itab INTO wa FROM tabix
             WHERE matnr = wa_copy-matnr.
    wa-dup = abap_true.
    MODIFY itab FROM wa.
  ENDLOOP.
ENDLOOP.
LOOP AT itab INTO wa.
  WRITE:/ wa-matnr, wa-dup.
ENDLOOP.
Regards,
Rich Heilman

Similar Messages

  • How to look for duplicate process instances?

    In Oracle BPM 11g, is there a good way to look for duplicate process instances based on process data attributes? For example, I have entered an instance of a process for 'John Smith' with a date of '4/1/2010' and I want to see if there is another instance in the same process with these same data values to evaluate as a potential duplicate. I believe we can write a java service to invoke the API to do this, but I am wondering if there is a better way within the process design to do this (XPath extension functions or soemthing?). It seems like this would be a common need.

    I am really looking for an approach to looking for duplicate instances within my process flow, not from EM. So, if the user starts a new instance of a process, I can check for another instance that appears to be a duplicate and direct the flow to a human activity to review the potential duplicate and make a decision as to whether to continue processing the new instance or reject it. My guess is that we need to us a service task to invoke java code which uses the API to investigate other instances with the same values. But, I was hoping for a simpler solution....I have to think that this is not too uncommon.

  • Look for duplicates fails

    From various merges I have done, i have about a thousand(s) duplicates in my address book that I am trying to zap. When I run the look for duplicates feature, it searches for a while but eventually the whole thing crashes. I've tried about 20 different times to run it.
    Any advice?
    Much appreciated.

    Hello Caryn:
    The only thing I can think of that might work is to trash a couple of preference files and restart:
    com.apple.addressbook.plist
    com.apple.addressbook.abd.plist
    Barry

  • Looking for Duplicate Contacts

    When Looking for Duplicate Contacts, I am getting an error message that my applications are out of space; and then have to force quit Contacts.
    I have never received this message before.  I have plenty of hard drive space available on my iMac.

    What is the exact, complete text of the warning message?

  • My Mac Book Pro address book has multiple addresses and when I try to "look for duplicates" it says there are none?

    My Mac Book Pro Address Book has multiple addresses for the same person from syncing before I cloud. When I try to "look for duplicates" it returns "no duplicates found" why does that happen? How can I correct it?

    For which version of Mail and OS?

  • When I try and look for duplicates on the menu the area is greyed out

    I have an issue on the software
    When I go to "VIEW" and then "SHOW DUPLICATE ITEMS" the selection is greyed out?

    What have you selected (to view)? Show Duplicate Items is not available in all views.
    For example, in the Music Library View, it is:
    But in the Podcasts Library View, it is not:

  • Is there any way to look for duplicate files on my hard drive?

    I have tones of duplicated songs, photos and videos! How can I get rid of them?

    Great advice Joe, it also depends a lot on Cesar's habits. 
    If he has rightfully imported music into iTunes and photos into iPhoto, then there should not be very many if any duplicates. Also it is just as important to not confuse ones iTunes and iPhoto Libraries as duplicates and mistakenly delete them.
    Then again if one has a bad habit of dropping stuff on the desktop or just anywhere, then is is going to be very difficult to clean up.

  • In address book, I can look for duplicates, but is there a way to validate or verify email addresses?

    The question states it pretty simply. At one point, I thought Thunderbird prompted me to do this, but I can't rediscover what I did.

    You can use this addon:
    *[https://addons.mozilla.org/thunderbird/addon/thunderplunger/ ThunderPlunger]

  • Optimizing a search for duplicate files in a filesystem

    We have a large directory that people have been dumping to for years (~200k files), and I want to go through and look for duplicate files. The first part of this was just scanning through and checking for duplicate file names.  I wrote a simple VI to serarch for duplicates, but it is very inefficiant because of multiple string comparisons. Even optimized as much as I could think to do, I'm only scanning about 1k files / minute.  I have attached my code - any help would be appreciated.
    Attachments:
    search.vi ‏22 KB

    This is trivial using the variant attributes mentioned earlier.  Attached is my method which uses the Variant Repository XNode I developed.  Not sure on performance comparisions.
    EDIT:  I'm betting the thing that will take the longest will be performing the MD5, I'm sure a CRC32 could be done faster which is probably just as good in this situation, or even a sum of the bytes of the file as a quick way of identifying the file.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Attachments:
    Find Duplicate Files.vi ‏23 KB

  • Search for duplicate

    hi there.
    i am running though an issue with looking for duplicates.
    right now. my vi is searching for the duplicate, once it is found, it will display "duplicate found".
    i am facing a new problem. lets say i have 10 devices and 10 positions those devices goes into my test box.
    position 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
    the device that read position 0, and 2 is close to one another. so when a device is put into position 0, it can be read on position 2. 
    and 2 can be read on position 4, 
    and 4 can be read on position 6,
    so then 1,3 --- and 3,5 ---- and 5,7 
    and so forth.
    thats because the hardware i designed didn't take into that consideration. 
    so now i think its best to fix the  software.
    does anyone have an idea of how to get rid of the DUPLICATE if the position is 2 positions away?
    i have created a vi that generated what i started. 
    Message Edited by krispiekream on 08-18-2008 06:00 PM
    Best regards,
    Krispiekream
    Attachments:
    duplicatefound.vi ‏21 KB
    untitled.PNG ‏14 KB

    i think this is what i have in mind.
    Message Edited by krispiekream on 08-18-2008 08:27 PM
    Best regards,
    Krispiekream
    Attachments:
    duplicatefound_mod2.vi ‏31 KB
    untitled.PNG ‏39 KB

  • How can I scan documents for duplicate cells?

    Hello!
    I've created 5 separate mailing lists in Numbers. I want to scan all five for duplicate email address. Can anyone think of a way to do this?

    Hi fp,
    Are the 'five mailing lists' in a single table? ...in multiple tables in a single document? ...in separate documents?
    Are you looking for duplicates in each list, or duplicates that may appear in separate lists?
    Here's an example, with two lists, each in a separate table.
    Column C shows the number of this each address appears in the list in 'This Table' only.
    C2, and filled down: =COUNTIF($B,$B2)
    Column D shows the total for each address in both tables.
    List 1::D2, and filled down: =COUNTIF($B,$B2)+COUNTIF(List 2 :: $B,$B2)
    List 2::D2, and filled down: =COUNTIF($B,$B2)+COUNTIF(List 1 :: $B,$B2)
    Tables that are in separate documents cannot be counted together as Numbers is unable to reference cells in other documents. The easiest way to handles these is to copy all the lists into a single document, code the rows to indicate which list it came from and its starting position in that list. the coding is to allow the combined list to be re-sorted into its original order to allow collecting each group's remaining members for pasting back to the original table.
    Trim the list by deleting any row showing a count that is greater than one. Numbers formulas respond to any change in the table, so the count of the remaining copies (or copy) of that address will be immediately updated as each copy of the address is removed. Remember to stop when the count reaches 1.
    Regards,
    Barry

  • Looking for exchange calendar sync groupcal *****

    Looking for exchange calendar sync system to replace sucky groupcal.
    I've had nothing but problems with it. I get duplicate calendars, duplicate calendar entries, and the daemon stops updating from the
    then the support folks are threatening to cut off support and no longer help me to fix their broken code!
    I wasted money and so much time on this app, is there anything else out there that does a better job?

    Not to mention that it doesn't work with Leopard now! I wish there was a way to get my Exchange calendar to sync to a third party that would sync with iCal 3.0. Since there is not support for CalDAV it would be nice if Exchange would support this!

  • Looking for some assistancte in GUI_DOWNLOAD

    Hi there,
    See I have this exercise I have to do here. Basically I have to create a program that will download the contects of SBOOK to my pc. I have to use GUI_DOWNLOAD in this exercise. Also, the user will have to input the path and file name of the file to be downloaded to. I have place appropriate error message on the screen as well but I'm not sure how to do this.Being relatively new to this, I tried looking for some samples and this is what I came up so far.
    REPORT  ZISTANZS_TRNG_EX9C.
    TABLES: SBOOK.
    PARAMETERS: FILEINP(30) DEFAULT 'c:\TEMP\wee.txt' OBLIGATORY.
    DATA: BEGIN OF ITAB OCCURS 100.
          INCLUDE STRUCTURE SBOOK.
    DATA: END OF ITAB.
    CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
             FILENAME            = FILEINP
             FILETYPE            = 'ASC'
             write_field_separator = 'X'
         TABLES
             DATA_TAB            = ITAB
         EXCEPTIONS
             FILE_OPEN_ERROR     = 1
             FILE_WRITE_ERROR    = 2
             OTHERS              = 3.
    Unfortunately, it doesn't work though. It keeps saying that my FILENAME is not the same data type as FILEINP? I'm asking for some assistance in how this can be properly solved? Any help would be appreciated /

    Hi,
    Please refer the code below:
    * File download, uses older techniques but achieves a perfectly
    * acceptable solution which also allows the user to append data to
    * an existing file.
      PARAMETERS: p_file like rlgrap-filename.
    * Internal table to store export data
      DATA: begin of it_excelfile occurs 0,
       row(500) type c,
       end of it_excelfile.
      DATA: rc TYPE sy-ucomm,
            ld_answer TYPE c.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query    = 'FE'  "File Exist?
                filename = p_file
           IMPORTING
                return   = rc.
      IF rc NE 0.                       "If File alread exists
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
    *          TITLEBAR              = ' '
    *          DIAGNOSE_OBJECT       = ' '
               text_question         = 'File Already exists!!'
               text_button_1         = 'Replace'
    *          ICON_BUTTON_1         = ' '
               text_button_2         = 'New name'
    *          ICON_BUTTON_2         = ' '
    *          DEFAULT_BUTTON        = '1'
    *          DISPLAY_CANCEL_BUTTON = 'X'
    *          USERDEFINED_F1_HELP   = ' '
    *          START_COLUMN          = 25
    *          START_ROW             = 6
    *          POPUP_TYPE            =
          IMPORTING
               answer                = ld_answer
    *     TABLES
    *         PARAMETER              =
          EXCEPTIONS
              text_not_found         = 1
              OTHERS                 = 2.
    * Option 1: Overwrite
        IF ld_answer EQ '1'.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
    *            BIN_FILESIZE            =
                 filename                = p_file        "File Name
                 filetype                = 'ASC'
    *       IMPORTING
    *            FILELENGTH              =
            TABLES
                data_tab                = it_excelfile   "Data table
            EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                OTHERS                  = 5.
          IF sy-subrc <> 0.
            MESSAGE i003(zp) WITH
                     'There was an error during Excel file creation'(200).
            exit. "Causes short dump if removed and excel document was open
          ENDIF.
    * Option 2: New name.
        ELSEIF ld_answer EQ '2'.
          CALL FUNCTION 'DOWNLOAD'
            EXPORTING
                 filename            = p_file          "File name
                 filetype            = 'ASC'           "File type
    *             col_select          = 'X'            "COL_SELECT
    *             col_selectmask      = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
    *                                                   "COL_SELECTMASK
                 filetype_no_show    = 'X'     "Show file type selection?
    *       IMPORTING
    *             act_filename        = filename_dat
            TABLES
                 data_tab            = it_excelfile    "Data table
    *            fieldnames          =
            EXCEPTIONS
                 file_open_error     = 01
                 file_write_error    = 02
                 invalid_filesize    = 03
                 invalid_table_width = 04
                 invalid_type        = 05
                 no_batch            = 06
                 unknown_error       = 07.
        ENDIF.
      ELSE.                               "File does not alread exist.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
    *          BIN_FILESIZE            =
               filename                = p_file         "File name
               filetype                = 'ASC'          "File type
    *     IMPORTING
    *          FILELENGTH              =
          TABLES
               data_tab                = it_excelfile   "Data table
          EXCEPTIONS
               file_write_error        = 1
               no_batch                = 2
               gui_refuse_filetransfer = 3
               invalid_type            = 4
               OTHERS                  = 5.
        IF sy-subrc <> 0.
          MESSAGE i003(zp) WITH
                   'There was an error during Excel file creation'(200).
          exit. "Causes short dump if removed and excel document was open
        ENDIF.
      ENDIF.
    Thanks,
    Sriram Ponna.

  • Look for my invoice from July 2010, bought in Washington DC

    I bought IPAD 1 , in Washington DC on July 2010,
    I need to look for the invoice, I paid around 650 US$ .

    You are not communicating with Apple when you post in these forums; we are all just fellow users. You will need to call the store from which you purchased the iPad and ask if they can provide a duplicate receipt. Whether they can provide a duplicate receipt three years after you made the purchase is doubtful, but you can ask.
    Regards.

  • Looking for Script Exchange-2007: Import-Mailbox Calendar Folder on multiple mailboxes {Distribution Group}

    Hi,
    I'm looking for a PowerShell script which will import a Calendar events into student's mailbox (Calendar). Those students are located in a distribution group and I would like to target the distribution group; I'm trying to simulate what I want to achieve
    in the below code example, I would appreciate if anyone jump in and advise.
    $Users = Import-Csv C:\users.csv | ForEach-Object{Get-DistributionGroup -Identity SC-1213} | Import-Mailbox -Identity $Users -PSTFolderPath c:\Calendar.pst -IncludeFolders '\Calendar' -StartDate -EndDate
    Much appreciated..
    Hussain

    The logic doesn't work unless you are using StartDate and EndDate for the period when you change the item.  As I said above, StartDate and EndDate are not the times when the meeting starts and ends - they are the times that the item was either added
    or modified in the mailbox.  Your filter was trying to pull items that were in the future.
    And as I also said above, if you import a modified item, the original is
    not going to be updated.  You will have a duplicate meeting
    on the calendar.  You would have to remove the original
    and import the updated item if this was how you wished to manage the updates.  This is not nearly as effective as
    sending meeting requests and updating those meetings.
    For example, if we do things the way you are doing them, and we add a "Student Appreciation Bonfire" meeting to the calendar for April 12 at "The Quad", we would do the following:
    On February 1, you get information for the meeting that needs to be imported
    You create this new meeting in the PST calendar - "Student Appreciation Bonfire"; Date April 12, start 8:00 AM, end 12:00 noon; Location The Quad
    You import the PST into everyone's calendar
    You receive a note on March 12 saying the venue has changed to The River Beach, so you update this meeting in your PST
    Since there are other calendar items in the PST, you import the update using StartDate of March 12 and EndDate of March 13 - the date that you changed the item, not the date the item occurs
    At this point, all users have two meetings on their calendar - the original and the update
    If, instead of doing it this way, you create a Student Actvities Calendar mailbox, you would handle it this way:
    On February 1, you get information for the meeting that needs to be imported
    You create this new meeting in the Corporate calendar - "Student Appreciation Bonfire"; Date April 12, start 8:00 AM, end 12:00 noon; Location The Quad
    You invite everyone to the meeting
    You receive a note on March 12 saying the venue has changed to The River Beach, so you update this meeting in that calendar and send out the update
    At this point, all users have only the one meeting on their calendar - the update
    Using the PST as the source for the meetings would work only for items that
    will not be changed - holidays are a good example.

Maybe you are looking for