Collect repeated entries in internal table

Hi,
I have an internal table with a field logk and prof..i have multiple entries for logk. i want to collect all multiple entries for a particular value of logk to put into error log.can u help me out.
Thanks ,
Anand.

if prof is a numeric tye field you can do like this
sort itab.
loop at itab.
collect itab into itab1.
endloop.
Here Itab1 must be of same structure as itab
Regards,
Ravi

Similar Messages

  • Deleting entry from internal table

    Hi Experts,
    i have the following internal table:
    data :    it_result1            TYPE   crmt_object_guid_tab
    and work area
    data : wa_result1 type crmt_object_guid.
    i have to delete a guid from internal table based on some condition.
    loop at it_resul1 into wa_result1
    if lv_priority eq priority.
    delete     this entry from internal table.
    endif.
    endloop..
    i tried using  delete table it_result with table key CRMT_OBJECT_GUID = wa_result. but this is giving syntax error.
    what should be done to delete the entry?
    Thanks and regards
    Shilpi

    Hi
    Check Syntax for DELETE operator on pressing F1
    1. DELETE itab.
    2. DELETE TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
    3. DELETE TABLE itab [FROM wa].
    4. DELETE itab INDEX idx.
    5. DELETE itab FROM idx1 TO idx2.
    6. DELETE itab WHERE logexp.
    7. DELETE ADJACENT DUPLICATES FROM itab.
    delete table it_result with table key CRMT_OBJECT_GUID = wa_result
    this is wrong
    delete  it_result where CRMT_OBJECT_GUID = wa_result
    Edited by: Lavanya K on Apr 22, 2009 10:20 AM

  • 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

  • How to delete the entries in internal table

    Hi Experts,
    I have 2 internal tables ,
    if i find any same entries of 2 internal tables,  i have to delete that entries in first internal table.
    Regards,
    Srinivasu

    hi check this..
    report .
    data:begin of itab occurs 0,
         f1 type c ,
         f2 type i,
         end of itab .
    data:begin of itab1 occurs 0,
         f1 type c ,
         end of itab1 .
         itab-f1 = 'A'.
         itab-f2 = 12.
         append itab .
         itab-f1 = 'b'.
         itab-f2 = 12.
         append itab .
         itab-f1 = 'c'.
         itab-f2 = 12.
         append itab .
         itab1-f1 = 'A'.
         append itab1 .
    loop at itab1 .
    read table itab with key f1 = itab1-f1 .
    if sy-subrc  = 0.
    delete itab where  f1 = itab1-f1 .
    endif .
    endloop.
    loop at itab.
    write:/ itab-f1,itab-f2.
    endloop.

  • Collecting spool list into internal table.

    Hey guys,
    Could you pls help me in how to take the output in spool list and collec the list into one internal table?
    i guess using GET_PRINT_PARAMETER does that? how to collect the list from the spool list.
    ambichan.

    Hi ambi,
    e.g.:
    SUBMIT y123...
                    EXPORTING LIST TO MEMORY
                    AND RETURN.
    CALL FUNCTION 'LIST_FROM_MEMORY'
         TABLES
              listobject = liste
         EXCEPTIONS
              not_found  = 1
              OTHERS     = 2.
    CALL FUNCTION 'LIST_TO_ASCI'
         EXPORTING
              list_index         = -1
         TABLES
              listasci           = tab
              listobject         = liste
         EXCEPTIONS
              empty_list         = 1
              list_index_invalid = 2
              OTHERS             = 3.
    LOOP AT tab.
    append tab to tab_total.
    endloop.
    free tab.
    regards Andreas

  • Problem in deleting entries from internal table

    i am selecting
               vrgar
                perio
                paobjnr
                belnr
                gjahr
                perde
                budat
                kndnr
                artnr
                frwae
                kursf
                rec_waers
                kaufn
                kdpos
                bukrs
                kokrs
                werks
                gsber
                vkorg
                vtweg
                spart
                rbeln
                rposn
                prctr
                pprctr
                kunnr
                land1
                regio
                kunwe
                kvgr1
                wwpmg
                zterm
                wwcst
                wwrst
                mvgr3
                wwseg
                wwcls
                wwesa
                prdha
                wwbun
                wwexd
                wwph1
                wwph2
                wwph3
                wwph4
                prat1
                prat2
                vrprs
                vv510
                vv508
                vv509
                vvqt2
                vv515
        INTO TABLE ct_ce11000 FROM ce11000
        WHERE paledger EQ gv_ledbo AND
              vrgar    EQ lc_vrgar AND
              belnr    GT uv_belnr AND
              gjahr    EQ pa_gjahr AND
              perde    EQ pa_perd AND
              bukrs    EQ pa_bukrs.
    now i awant to delete all those entries from my internal table ct_ce11000 where my plant (WEKRS) and company code (BUKRS)
    i am writting
    loop at ct_ce11000 into wa_ce11000.
    if wa_ce11000-werks ne wa_ce11000-bukrs.
    now how can i delete all the entries from nmy internal table (ct_ce11000)  when plant and company code is not same
    pls help me  with logic.
    thank you for helping me

    Hello Guys,
    It is not advisable to delete the entries from the internal table you are looping upon. See this thread: [Sy-tabix in loop : Doubt|Sy-tabix in loop : Doubt]
    And to answer the OP's question select data into some local internal table & based on the condition populate your final table. Creating a local table of the same type as the final table will not create too much performance overhead
    Cheers,
    Suhas

  • Problem in collecting Spool data into internal table

    Hi ,
    i need to download  spool request data into internal table,
    after collecting i need to loop it and delete some records,
    for this i am using  Fm  RSPO_RETURN_ABAP_SPOOLJOB
    but getting some extra spaces and lines,unable to get right format.
    please help me in this issue to prepare internal table like normal internal table with spool id.
    Regards
    sarath

    Hi ,
    Thanks for the reply,
    My requirement is like i need to collect all the records from the spool to Internal table and
    after that based on one field in the internal table i have to separate error records by deleting sucess records from that internal table(from spool),
    for that i have to loop the internal table and need to count the error records, after that download to excel and mail functionalities
    required for that .
    so please help me in this.
    Regards
    sarath

  • Duplicate Entries in Internal table

    Hi All,
    As per my requirement
    1. The internal table is the input.
    2. I need the duplicate records of the internal table with the combination of 2 key fields.
    3. I should not use SORT because i need the index number in order as per in the table .
    EX : Take Table MSEG.
    Take key fields as MBLNR and WERKS.
    I want the duplicate records of the combination of these 2 key fields.
    The *Index Number * should not to be changed as per the table entry. ( So i avoided sorting the internal table)
    Kindly give some solutions.
    Thanks,
    Pradeep.
    Moderator message : Duplicate post locked,follow forum Rules of Engagement. Thread locked.
    Edited by: Vinod Kumar on Mar 1, 2012 4:59 PM

    Hi Pradeep,
    Try this...
    first you copy your internal table to another temporary table of same type.
    itab_temp[] = itab[].
    sort itab_temp[].
    DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MBLNR WERKS.
    LOOP AT ITAB_TEMP INTO WA_ITAB1.
    DO.
        READ TABLE ITAB INTO WA_ITAB2 WITH KEY MBLNR = WA_ITAB1-MBLNR AND  WERKS = WA_ITAB1-WERKS.
        IF SY-SUBRC EQ 0.
             APPEND WA_ITAB2 TO ITAB_NEW.
        ELSE.
             EXIT.
        ENDIF.
    ENDDO.
    ENDLOOP.
    you may get the duplicate records in itab_new.

  • Deleting entries from internal table

    hi
    i have an internal table. column one value can vary from A to Z. i mean some records can have A, some entries can have 'C like that. now i want to delete all the entries where column one value is not equal to A or C. can i do this in one single statement?
    i tried delete with where condition but it did not work. if i use an and condition in where clause it won't obviously work. if i use or condition it will only give entries with either A or C, but not both.
    thanks

    Moderator message - Basic question - thread locked
    Rob

  • Sample code to find duplicated entries in internal table and mark them?

    We have one internal table called itab1 which contains the following fields:
    f1 (key field)
    f2 (non-key field)
    f3 (non-key field)
    The business scenario is f1, f2, and f3 are one to one relationship to each other, or in other word, f2 or f3 can't be duplicated with the the same values for different f1 (key field) records. We will move the check result of the duplication into another internal table itab2 which contains f1, f2, f3, f4, and f5 where f1, f2, and f3 are the same ones as in itab1, f4 will get the value "Yes" to mark duplicated for f2 (or "No" to mark non-duplicated), and f5 will get the value "Yes" to mark duplicated for f3 (or "No" to mark non-duplicated).
    We know that through the loop of itab1, the above logic can be done to fill in f4 and f5 value for each row with either "Yes" or "No".
    Just give an example of how itab2 will look like after the coding:
    f1----f2--f3--f4(f2 duplicated?)---f5(f3 duplicated?)
    A----01-X0YesNo--
    B----01-X1YesYes--
    C----02-X1NoYes--
    Could any ABAP expert here show us the sample code to generate itab2 in loop of itab1 to find the duplicated entries of f2 and f3 and then populated the corresponding row values for f4 and f5 with "Yes" or "No"? We will give you reward points!

    TYPES: BEGIN OF ty_1,
    f1,
    f2(2),
    f3(2),
    f4,
    f5,
    END OF ty_1.
    TYPES: BEGIN OF ty_2,
    type(2),
    value(2),
    END OF ty_2.
    DATA: itab1 TYPE STANDARD TABLE OF ty_1 WITH HEADER LINE,
          itab2 TYPE TABLE OF ty_2 WITH HEADER LINE.
    DATA: f2_c TYPE sy-tabix VALUE 0,
         f3_c TYPE sy-tabix VALUE 0,
         curr_f2 LIKE itab1-f2,
         curr_f3 LIKE itab1-f3.
    itab1-f1 = 'A'.
    itab1-f2 = '01'.
    itab1-f3 = 'X0'.
    APPEND itab1.
    itab1-f1 = 'B'.
    itab1-f2 = '01'.
    itab1-f3 = 'X1'.
    APPEND itab1.
    itab1-f1 = 'C'.
    itab1-f2 = '02'.
    itab1-f3 = 'X1'.
    APPEND itab1.
    SORT itab1 BY f1 f2 f3 AS TEXT.
    LOOP AT itab1.
      IF sy-tabix EQ 1.
        curr_f2 = itab1-f2.
        curr_f3 = itab1-f3.
      ENDIF.
      IF itab1-f2 NE curr_f2.
        f2_c = 0.
        curr_f2 = itab1-f2.
      ENDIF.
      IF itab1-f3 NE curr_f3.
        f3_c = 0.
        curr_f3 = itab1-f3.
      ENDIF.
      f2_c = f2_c + 1.
      f3_c = f3_c + 1.
      IF f2_c > 1.
        itab1-f4 = 'X'.
        MODIFY itab1.
        itab2-type = 'f2'.
        itab2-value = itab1-f2.
        APPEND itab2.
      ENDIF.
      IF f3_c > 1.
        itab1-f5 = 'X'.
        MODIFY itab1.
        itab2-type = 'f3'.
        itab2-value = itab1-f3.
        APPEND itab2.
      ENDIF.
    ENDLOOP.
    DELETE ADJACENT DUPLICATES FROM itab2.
    LOOP AT itab2.
      IF itab2-type = 'f2'.
        LOOP AT itab1 WHERE f2 = itab2-value AND f4 NE 'X'.
          itab1-f4 = 'X'.
          MODIFY itab1.
        ENDLOOP.
      ELSE.
        LOOP AT itab1 WHERE f3 = itab2-value AND f5 NE 'X'.
          itab1-f5 = 'X'.
          MODIFY itab1.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    Edited by: Ramiro Escamilla on Apr 5, 2008 1:45 AM
    changed the code, now should work

  • Checking the entries in internal table with Ztable

    Hi ,
      Please go through the below requirement and please give me the code.
    I am having an internal table ITAB with 5 entries and also having a Ztable with 10 entries. I should check weather any of the entry in the internal table ITAB  is present in the Ztable or not?
    Please give me the code
    Thanks in advance,
    Ajay

    Select f1 f2 f3 from ztable into itab1 "say ur ztab entries
    *now say ur itab contents are in itab2.
    sort itab2 by f1 " set the primary key in both .
    delete adjacent duplicates from itab2 comparing f1.
    Loop at itab2.
    read table itab1 with key f1 =  itab2-f1.
    if sy-subrc eq 0 .
    write:/ 'Entry exists '.
    endif.
    endloop.
    On every sy-subrc hit i.e eq 0 write statement tells u a hit and no of times = number of the entries.
    Vijay.

  • Checking every entry into internal table

    hii i have taken material from lips in first internal table and material from vepo in second internal table
    now i want only those entries in second table which r present in first table.
    one delivery can have multiple materials in it.
    please provide logic.. <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Feb 12, 2008 2:45 PM

    LOOP AT itab2.
    lv_index = sy-index.
        READ TABLE itab1 WITH KEY matnr = itab2-matnr.
        IF sy-subrc NE 0.
          DELETE itab2 AT INDEX lv_index.
         ENDI.
    ENDLOOP.
    At the end of loop itab2 will have only entries available in itab1.
    Regards
    Sudhir Atluru

  • Reg deleting entries from internal table

    Hi experts,
       I have two internal tables , ITAB1 and ITAB2 (same structure), i like to delete the records from ITAB1 which are in ITAB2 without looping .How it can be done?
    regards,
    Kannan

    Lozan,
    itab1 is having 1,2,3,4.
    itab2 is having 1,2,5,6,7.
    Now I move the contents in itab1 and itab2 to itab3.
    itab3 is having now 1,2,3,4,1,2,5,6,7.
    Now I will sort this itab3,thus itab3 is now having
    1,1,2,,2,3,4,5,6,7.
    <b>Now,if  I use delete adjacent duplicates from itab3,will it won't result in
    1,2,3,4,5,6,7 in itab3?</b>
    K.Kiran.
    Message was edited by:
            Kiran K
    Message was edited by:
            Kiran K

  • Duplicate Entries in Internal Tables

    Hallo Friends,
    It Would be nice if some one let me know, if there is a way in ABAP to select the duplicates records in an internal tables.
    Lets say I have two internal tabels, itabA have following structure:
    BNAME  |          WORKAREA   |   ROLES
    abc |             wa1 |          ro1
    cde  |            wa1 |          ro1
    cde  |      wa3 |          rol..
    abc  |      wa2 |          rol2
    xyz |       wa1 |          rol3
    xyz  |      wa3  |         rol2..
    the itabB have the following structure:
    WORKAREA |      ROLES|  
    wa1   |         rol1
    wa2  |        rol1
    wa3  |          rol1
    wa4  |          rol1
    Now problem is, I need to select the common WorkAreas from itabA ( which is commom in all BNAME ) in above example it will be workarea wa1. as it is commom in all i.e ( abc ,cde and xyz). I need to select this commom workarea, and then mark it with some flage in itabB ( to display that this workarea is common among the users...)
    Would be nice if some one let me know, is there any way I can select the duplicate rows in an internal table or I have to go one by one and then do some kind of comparision.
    Many thanks,
    Thx in advance....
    Haider

    Hi marek,
    below information might help you.
    The first criterion for comparing internal tables is the number of lines they contain. The more lines an internal table contains, the larger it is. If two internal tables contain the same number of lines, they are compared line by line, component by component. If components of the table lines are themselves internal tables, they are compared recursively. If you are testing internal tables for anything other than equality, the comparison stops when it reaches the first pair of components that are unequal, and returns the corresponding result.
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA: ITAB LIKE TABLE OF LINE,
    JTAB LIKE TABLE OF LINE.
    DO 3 TIMES.
    LINE-COL1 = SY-INDEX.
    LINE-COL2 = SY-INDEX ** 2.
      APPEND LINE TO ITAB.
    ENDDO.
    MOVE ITAB TO JTAB.
    LINE-COL1 = 10. LINE-COL2 = 20.
    APPEND LINE TO ITAB.
    IF ITAB GT JTAB.
    WRITE / 'ITAB GT JTAB'.
    ENDIF.
    APPEND LINE TO JTAB.
    IF ITAB EQ JTAB.
    WRITE / 'ITAB EQ JTAB'.
    ENDIF.
    LINE-COL1 = 30. LINE-COL2 = 80.
    APPEND LINE TO ITAB.
    IF JTAB LE ITAB.
    WRITE / 'JTAB LE ITAB'.
    ENDIF.
    LINE-COL1 = 50. LINE-COL2 = 60.
    APPEND LINE TO JTAB.
    IF ITAB NE JTAB.
    WRITE / 'ITAB NE JTAB'.
    ENDIF.
    IF ITAB LT JTAB.
    WRITE / 'ITAB LT JTAB'.
    ENDIF.
    The output is:
    ITAB GT JTAB
    ITAB EQ JTAB
    JTAB LE ITAB
    ITAB NE JTAB
    ITAB LT JTAB
    This example creates two standard tables, ITAB and JTAB. ITAB is filled with 3 lines and copied to JTAB. Then, another line is appended to ITAB and the first logical expression tests whether ITAB is greater than JTAB. After appending the same line to JTAB, the second logical expression tests whether both tables are equal. Then, another line is appended to ITAB and the third logical expressions tests whether JTAB is less than or equal to ITAB. Next, another line is appended to JTAB. Its contents are unequal to the contents of the last line of ITAB. The next logical expressions test whether ITAB is not equal to JTAB. The first table field whose contents are different in ITAB and JTAB is COL1 in the last line of the table: 30 in ITAB and 50 in JTAB. Therefore, in the last logical expression, ITAB is less than JTAB.
    reward with points and close the thread if your question is solved
    regards,
    venu.

  • Delete entries from internal table

    Hello friends,
                        I have a screen on which im displaying a table, now i have also provided an delete button which deletes the selected record.
                      the record which i have written is
    GET CURSOR FIELD FLD LINE IND.
      READ TABLE ITAB2 INDEX IND.
      DELETE ZCTA_STONE_DET FROM ITAb2.
      IF IND IS NOT INITIAL.
        DELETE ITAB2 INDEX IND.
      ENDIF.
    but there is problem with this code,when ever the user scrolls the wrong data gets deleted.
    so wat is the proper code to delete the record from the display table

    Hi,
    This maybe possible B'coz the Line Number is taken considering the Headers so you should subtract 1 or 2 depending on the no. of lines in Header and then delete the record.
    so write the Code as
    GET CURSOR FIELD FLD LINE IND.
    READ TABLE ITAB2 INDEX IND.
    DELETE ZCTA_STONE_DET FROM ITAb2.
    SUBTRACT 1 FROM IND.
    IF IND IS NOT INITIAL.
    DELETE ITAB2 INDEX IND.
    ENDIF.
    Regards,
    Sunil

Maybe you are looking for