Delete lines from internal table

Hello experts!
I have two internal tables.
select options sa_tknr and gt_versand_plan.
sa_tknr-low contents transportation-Nr.
gt_versand_plan has transportation-Nr too (gt_versand_plan-tknum).
How can I delete all transportation-Nr from
gt_versand_plan which dont' appear in sa_tknr-tknum.
THX
sas

Hi
check this statement.
<b>delete gt_versand_plan where not tknum in sa_tknr.</b>
<b>Reward points for useful Answers</b>
Regards
Anji

Similar Messages

  • Efficiently deleting lines from internal table based on column comparison

    Hi all,
    let's assume, I have the following internal table MY_TAB:
    COL_1 | COL_2 | COL_3
    A       1       1
    B       2       2
    C       3       3
    D       3       4
    E       3       5
    I'd like to delete all rows, where the values in COL_2 and COL_3 are equal. That is, in the above table, the rows for A, B and C.
    What's the most performant / fastest and efficient way to do this?
    Thanks for any hints in advance!
    Best regards,
    Philipp

    I do not understand other proposal.
    The are two solutions possible
    LOOP AT itab INTO wa.
       IF ( wa-col2 = wa-col3).
         DELETE itab INDEX sy-tabix.
       ENDIF.
    ENDLOOP.
    If memory is not an issue and if many lines are to be deleted, then the APPEND in a new table is better.#
    I would use that one in all cases where the conditions are complicated.
    LOOP AT itab INTO wa.
       IF ( wa-col2 <> wa-col3).
         APPEND wa TO itab2.
       ENDIF.
    ENDLOOP.
    refresh itab.
    itab[] = itab2[].
    Siegfried

  • How to choose in Delete Duplicates from internal table?

    Now I need to delete Duplicates from internal table,
    So at first I sort
    than I delete duplicate
    Sort itab1 BY Company_Code  Asset_No Capital_Date.
          DELETE ADJACENT DUPLICATES FROM itab1 COMPARING Company_Code  Asset_No  Capital_Date
    Company_Code
    Asset_No
    Capital_Date
    Remark
    BC35
    1515593
    20021225
    Helen
    BC35
    1515593
    20021225
    Common Asset
    BC35
    1515594
    20030109
    Judy
    BC35
    1515594
    20030109
    Common Asset
    But here comes my problem~If I want to delete the Common Asset in Remark Column,how I let it choose the right one to do it?

    Hi Jack
    Try the below coding..
    Report zsamp.
    types: begin of t_tab,
            comp_code(4) type c,
            ***_no(7) type n,
            cap_date type d,
            remark type string,
            end of t_tab.
    data: i_tab type TABLE OF t_tab,
           w_tab type t_tab.
    w_tab-comp_code = 'BC35'.
    w_tab-***_no = '1515593'.
    w_tab-cap_date = '20021225'.
    w_tab-remark = 'Helen'.
    append w_tab to i_tab.
    w_tab-comp_code = 'BC35'.
    w_tab-***_no = '1515593'.
    w_tab-cap_date = '20021225'.
    w_tab-remark = 'Common Asset'.
    append w_tab to i_tab.
    w_tab-comp_code = 'BC35'.
    w_tab-***_no = '1515594'.
    w_tab-cap_date = '20030109'.
    w_tab-remark = 'Judy'.
    append w_tab to i_tab.
    w_tab-comp_code = 'BC35'.
    w_tab-***_no = '1515594'.
    w_tab-cap_date = '20030109'.
    w_tab-remark = 'Common Asset'.
    append w_tab to i_tab.
    sort i_tab by remark.
    delete ADJACENT DUPLICATES FROM i_tab COMPARING remark.

  • 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

  • Delete records from internal table

    hi all,
    i want to delete records from intenal table which are starting with a particular starting number .
    eg internal table
    10000
    20000
    90000
    91000
    92000
    88880
    i want delete the records starting with 9 i.e. 90000 91000 92000.
    Thanks in Adv
            RAJ

    You can test this piece of code.
    DATA:
    i_tab TYPE STANDARD TABLE OF mara,
    wa_tab TYPE mara.
    wa_tab-matnr = '1000'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1002'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1003'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '2001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '3001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '4010'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Aug 8, 2008 4:49 PM

  • Delete lines from iternal table

    Hi All!
    The problem what I'm having is I have to delete
    all the entries from the internal table which are
    lets say equal 'XXXXXX'
    regards
    sas
    data lt_itab type standard table of IS_PDATFU.
    data wa_itab type IS_PDATFU.
    data: lt_roles   type BAPIBUS1006_BPROLES  occurs 0 with header line,
          lt_return  type standard table of BAPIRET2,
          lv_partner type BU_PARTNER.
    lt_itab[] = l_pdatfu_tab[].
    LOOP AT lt_itab into wa_itab.
    CALL FUNCTION 'BUPA_ROLES_GET_2'
      EXPORTING
        IV_PARTNER            = wa_itab-IPPERS 'PersID
      IV_PARTNER_GUID       =
      IV_DATE               = SY-DATLO
      TABLES
        ET_PARTNERROLES       = lt_roles
        ET_RETURN             = lt_return.
    IF lt_roles-PARTNERROLE EQ 'XXXXXX'.
    delete this lines from lt_itab[] ????
    ENDIF.
    ENDLOOP.

    So u need to use DELETE ITAB:
    LOOP AT lt_itab into wa_itab.
    CALL FUNCTION 'BUPA_ROLES_GET_2'
    EXPORTING
    IV_PARTNER = wa_itab-IPPERS 'PersID
    IV_PARTNER_GUID =
    IV_DATE = SY-DATLO
    TABLES
    ET_PARTNERROLES = lt_roles
    ET_RETURN = lt_return.
    IF lt_roles-PARTNERROLE EQ 'XXXXXX'.
      delete lt_itab.
    ENDIF.
    ENDLOOP.
    Max
    Edited by: max bianchi on Feb 12, 2008 6:17 PM

  • Delete duplicate from internal table

    HI Abapers,
    I have a query on how to remove the duplicates from an internal table
    My internal table data is as follows :
    Cno    Catg1  Catg2
    01       0         1000
    01      2000         0
    I want to get only one record as
    01   2000  1000
    How to  get the result.
    I tried sorted by cno and used delete duplicates but it was not helpful.
    Is there any other alternative to get this done
    Please help me.
    Regards,
    Priya

    check it out with delete adjacent duplicate records
    Deleting Adjacent Duplicate Entries
    To delete adjacent duplicate entries use the following statement:
    DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>
                                      [COMPARING <f1> <f 2> ...
                                                 |ALL FIELDS].
    The system deletes all adjacent duplicate entries from the internal table <itab>. Entries are duplicate if they fulfill one of the following compare criteria:
    Without the COMPARING addition, the contents of the key fields of the table must be identical in both lines.
    If you use the addition COMPARING <f1> <f 2> ... the contents of the specified fields <f 1 > <f 2 > ... must be identical in both lines. You can also specify a field <f i > dynamically as the contents of a field <n i > in the form (<n i >). If <n i > is empty when the statement is executed, it is ignored. You can restrict the search to partial fields by specifying offset and length.
    If you use the addition COMPARING ALL FIELDS the contents of all fields of both lines must be identical.
    You can use this statement to delete all duplicate entries from an internal table if the table is sorted by the specified compare criterion.
    If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4.

  • Delete Duplicates from internal table with object references

    Hi
    How can I delete duplicates from an internal table in ABAP OO based on the value of one of the attributes?
    I have created a method, with the following code:
      LOOP AT me->business_document_lines INTO l_add_line.
        CREATE OBJECT ot_line_owner
          EXPORTING
            i_user      = l_add_line->add_line_data-line_owner
            i_busdoc = me->business_document_id.
          APPEND ot_line_owner TO e_line_owners.
      ENDLOOP.
    e_line_owners are defined as a table containing only object references.
    One of the attribute of the object in the table is called USER. And I would like to do a "delete ADJACENT DUPLICATES FROM e_line_owners", based on that attribute.
    How can do this?
    Regards,
    Morten Nielsen

    Hello Morten
    Assuming that the instance attribute is <b>public </b>you could try to use the following coding:
      SORT e_line_owners BY table_line->user.
      DELETE ADJACENT DUPLICATES FROM e_line_owners
        COMPARING table_line->user.
    However, I am not really sure (cannot test myself) whether <b>TABLE_LINE</b> can be used together with SORT and DELETE.
    Alternative solution:
      DATA:
         ld_idx    TYPE sy-tabix.
      LOOP AT e_line_owners INTO ls_line.
        ld_idx = syst-tabix + 1.
        LOOP AT e_line_owners TRANSPORTING NO FIELDS FROM ld_idx
                       WHERE ( table_line->user = ls_line->user ).
          DELETE e_line_owners INDEX syst-tabix.
        ENDLOOP.
      ENDLOOP.
    Regards
      Uwe

  • 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

  • DELETED rows from internal table

    Hi Experts,
    If I delete row/s from an internal table
    using the command DELETE ADJACENT DUPLICATES,
    is there a way to get these deleted rows.
    Thanks in advance.
    Rose

    Hi roselie,
    1. ofcourse not.
    2.hence, before that,
      u can declare another internal table,
      similar to original,
      and use like this.
    3. ITAB1[]   = ORIGINALITAB[].
    regards,
    amit m.

  • Deleting block from internal table with AT / ENDAT

    Hi.
    I have the following code:
    sort itab by pred_doc.
    loop at itab into wa_cust.
    At end of pred_doc.
    sum.
    write :/ wa_cust-pred_doc, wa_cust-amount.
    if wa_cust-amount = 0.
    Delete entire block of this pred_doc
    endif.
    endat.
    endloop.
    Within that "IF" statement, I want to delete the entire block (all entries with that pred_doc).  How do I do this?  I'm not sure of the syntax.  In other words, I just need to do subtotals of the internal table by pred_doc on amount.  If the subtotal equals zero, the records for that pred_doc need to be removed from the internal table. 
    Thanks,
    Clay

    Hi,
    I agree with Rob. Use two internal tables for this purpose.
    data: itab1 like itab. New internal table which will hold the required entries
    sort itab by pred_doc.
    loop at itab into wa_cust.
    At end of pred_doc.
    sum.
    write :/ wa_cust-pred_doc, wa_cust-amount.
    if wa_cust-amount ne 0. " If the workarea has the subtotal entry with amount not equal to zero, then transfer it to a new internal table
    append wa_cust to itab1
    endif.
    endat.
    endloop.
    Now itab1 will contain your required entries. But please note that this will be the 'summed up' entries and not the the individual entries before summing up.
    Hope this helps!
    Cheers,
    Mahesh

  • 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

  • Delete row from internal table using field symbol.

    Hi friends,
      I created dynamic internal table using field symbol. I want to delete some data using where clause.
    for example. i want to use like,
        DELETE <FS> WHERE KUNNR = WA_KNA1-KUNNR.
    Like the above statment it won't work. How i can use delete with where clause in field symbols.
    Hope any one can help me.
    Thanks and regards
    Srikanth. S

    hi Srikanth,
    I think you have to LOOP through the whole internal table and check each line and decide to delete or not:
    LOOP at <itab> INTO <wa>.
    ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <wa> TO <field>.
    CHECK <field> IS ASSIGNED.
    IF <field> EQ WA_KNA1-KUNNR.
    DELETE ...
    ENDIF.
    UNASSIGN <field>.
    ENDLOOP.
    hope this helps
    ec

  • Delete records from internal table using another internal table

    HI,
    I have two internal tables itab1 and itab2 which have same records initially.Later some records of itab2 are deleted .Then i want to delete those records from itab1 also ie,those records not found in itab2 .Is there any method other than looping.
    So that itab1 again becomes equal to itab2.
    Thanks in advance.
    Sowmya.

    Soumya,
    Itab1 , Itab2 .
    Before deleting the records from itab2  move those records to one more internal table itab3.
    Now you have deleted records  of itab2  in itab3.
    SORT ITAB3,ITAB1 by your main key field.
    LOOP AT itab3.
      READ TABLE ITAB1 WITH KEY key field = itab3-
      keyfield.
    IF sy-subrc EQ 0.
    DELETE itab1 where keyfield eq itab3-keyfield.
    ENDIF.
    ENDLOOP.

  • 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

Maybe you are looking for