Deleting from Internal table.....

Hi All,
I have two internal tables with same structure like: IT_REC_LIST and IT_REC_LIST_DEL.
I have 10 records in this internal table: IT_REC_LIST and same 5 records in this internal table: IT_REC_LIST_DEL. I don’t have any key fields.
So I want to delete those 5 records from IT_REC_LIST. Could you please let me know hw to write the code, when I write like below its going for dump.
DELETE IT_REC_LIST [] FROM IT_REC_LIST_DEL [].
Akhitha.

Hello,
You can do like :
loop at IT_REC_LIST .
read table IT_REC_LIST_del with key field1 = IT_REC_LIST-field1.
if sy-subrc eq 0.
delete IT_REC_LIST.
endif.
endloop.
<REMOVED BY MODERATOR>
Vasanth
Edited by: Alvaro Tejada Galindo on Feb 19, 2008 5:28 PM

Similar Messages

  • Delete from internal table

    Hi,
    I want to delete from internal table some regords.
    I write code:
    delete  isrot where bldat < '01.09.2005'.
    it doesn't work, what is wrong?
    regards,
    Joanna

    hi,
    you write the statement like....
    <b>delete FROM isrot where bldat < '01.09.2005'.</b>
    now it will work...
    To select the lines that you want to delete using a condition, use the following:
    <b>DELETE FROM <target> WHERE <cond> .</b>
    All of the lines in the database table that satisfy the conditions in the WHERE clause are deleted. The FROM expression must occur between the keyword and the database table.
    You should take particular care when programming the WHERE clause to ensure that you do not delete the wrong lines. For example, if you specify an empty internal table in a dynamic WHERE clause, all of the lines in the table are deleted.
    If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4. SY-DBCNT contains the number of lines deleted.
    follow this link for more information on internal table operation.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3aef358411d1829f0000e829fbfe/content.htm
    regards,
    Ashok Reddy
    Message was edited by:
            Ashok Reddy

  • Deletion from internal table

    Hi,
      My requirement is that I have to delete the duplicate values before doing any manupilation of data.. so for this I have written the code...
    *Deleting all the duplicate entries comparing group code, GL *& GL Suffix
      IT_INPUT_TEMP[] = IT_INPUT[].
      SORT IT_INPUT_TEMP BY GRCODE GL GLSUF.
      DELETE ADJACENT DUPLICATES
             FROM IT_INPUT_TEMP COMPARING GRCODE GL GLSUF.
    Now with the remaining values in the internal table I have to check the 3rd field i.e. GLSUF & if it = '00000' (5 zeros)... i have to delete those entries...
    For this I have written...
    Deleting enteries where the GL Suffix is zero.
      IF IT_INPUT_TEMP-GLSUF = 00000.              
        DELETE IT_INPUT_TEMP.                      
      ENDIF.                                                                               
    It gives me a dump saying "Invalid_Table_Index"...
    Prior to this I have also checked up by using Index function.
    Deleting enteries where the GL Suffix is zero.
      IF IT_INPUT_TEMP-GLSUF = 00000.              
        DELETE IT_INPUT_TEMP index l_tabix.                      
      ENDIF.
    Can anyone tell me where I am wrong??..
    Thank You & Regards,
    -S.

    Hi S,
    Your code extract
    * Deleting enteries where the GL Suffix is zero.
    IF IT_INPUT_TEMP-GLSUF = 00000.
      DELETE IT_INPUT_TEMP.
    ENDIF.
    Either this should be in a loop(which is unnecessary if all you are trying to achieve is deleting records), or you can try the option with 'WHERE' clause as mentioned in the above post.
    DELETE FROM IT_INPUT_TEMP WHERE GLSUF = '00000'.
    Regards,
    Srinivas

  • Deleting from Internal Table (dynamic)

    Hi,
    I have an Internal table, which will contain daily movements for plants per material.
    The internal table will contain 4 plants per material, with more than 1 material.
    Now, i have four columns. If all of those columns for that material and for all plants for that material equal zero, i want to delete the specific record.
    For example
    Material     Plant      Daily 1  Daily 2  Daily 3  Daily 4
    102            1           0          0           0          0
    102            2           0          0           0          0
    102            3           0          0           0          0
    102            4           0          0           0          0
    So, these 4 records should be deleted. However, say on of the daily columns will equal 1, then keep the 4 records (they are linked by material and plant.)
    How do I do this?
    Points will be rewarded and all help will be greatly appreciated.
    Thanks,
    John

    Check this.
    DATA: BEGIN OF itab OCCURS 0,
            matnr LIKE marc-matnr,
            werks LIKE marc-werks,
            daily1 TYPE i,
            daily2 TYPE i,
            daily3 TYPE i,
            daily4 TYPE i.
    DATA: END OF itab.
    DATA: itab_per_matnr LIKE itab OCCURS 0 WITH HEADER LINE,
          wa_itab        LIKE itab.
    itab_per_matnr[] = itab[].
    LOOP AT itab INTO wa_itab.
    *-- check if there is at least one non-zero record for this material
      LOOP AT itab_per_matnr WHERE matnr = wa_itab-matnr
                               AND ( daily1 > 0 OR
                                     daily2 > 0 OR
                                     daily3 > 0 OR
                                     daily4 > 0 ).
        EXIT
      ENDLOOP.
      IF sy-subrc <> 0.
        DELETE itab WHERE matnr = wa_itab-matnr.
      ENDIF.
    ENDLOOP.

  • Deleting from Internal Tables

    Hi SDN Friends... Today I bring an easy question. But I still reward as always.
    Supose I have two internal tables of same type. Only one field.
    They re filled like the example below.
    Itab1
    01
    02
    03
    04
    05
    06
    Itab2
    02
    04
    06
    08
    10
    I want to remain only with the register that are containned in both table.
    FinalItab
    02
    04
    06
    What is the best way to do this in case of performance?
    Message was edited by:
            Jose Oliveira

    Let me join this funny
    Copy all above and these to conpare performance also!
    REPORT ZTEST.
    *[ DECLARE ]*******************
    DATA: begin of tab01 occurs 0,
            value type I,
          end of tab01.
    DATA: begin of tab02 occurs 0,
            value type I,
          end of tab02.
    *[ PREPARE ]*******************
    tab01-value = '1'.
    append tab01.
    tab01-value = '2'.
    append tab01.
    tab01-value = '3'.
    append tab01.
    tab01-value = '4'.
    append tab01.
    tab01-value = '5'.
    append tab01.
    tab01-value = '6'.
    append tab01.
    tab02-value = '2'.
    append tab02.
    tab02-value = '4'.
    append tab02.
    tab02-value = '6'.
    append tab02.
    *[ BEFORE ]*********************
    Write 'TAB01'.
    Loop at tab01.
      write / tab01-value.
    endloop.
    Write / 'TAB02'.
    Loop at tab02.
      write / tab02-value.
    endloop.
    *[ PROCESS ]********************
    data: min like tab02-value,
          max like tab02-value.
    sort: tab01, tab02.
    loop at tab02.
      max = tab02-value.
      DELETE tab01 where value > min and value < max.
      min = tab02-value.
    endloop.
    *[ AFTER ]**********************
    Write /'** AFTER DELETE **'.
    Write 'TAB01'.
    Loop at tab01.
      write / tab01-value.
    endloop.
    Write / 'TAB02'.
    Loop at tab02.
      write / tab02-value.
    endloop.

  • To get recent timestamp records from internal table

    hi all,
      i have one requirment
      i'm storing error messages in one table  while creating a sales order basing on timestamp
      which is of this format yyyy-mm-dd hh:mm:ss (random Number) 
      if i want to see the error messages left i'm getting all the error messages displayed
      for example i have created a sales order
    i got 10 errors displayed
    i have rectified 5 errors ... if i again display error messages the 10 errors + the 5 errors is getting displayed
    i want to display the 5 error messages only not the previous messages from internal table
    basing on timestamp current one has to displayed remaining has to deleted from internal table.

    I thought we used Sales Order Incompletion process for this....  but, if you're recreating the errors list every time you save with a create or change transaction then, at save, delete all rows in your error table for this document.   Then get your errors and update your db table from your current errors table.   From this viewpoint, the timestamp is not relevant.

  • 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 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.

  • To delete duplicate records from internal table

    hi friends,
    i have to delete records from internal table based on following criterion.
    total fields are 7.
    out of which  if 4 fields are same and 5th field is different,then both records must be deleted.
    in case all five fields are same,the program should do nothing.
    for example.
    if there are 3 records as follows
    a1 b1 c1 d1 e1 f g
    a1 b1 c1 d1 e2 w r
    a1 b1 c1 d1 e1 j l
    then first two records should be deleted as four fields are same but fifth(e) field differs.
    but third record should remain as it is evenif first five fields are same for first and third record.
    values of last two fields need not to be consider for deleting the records.

    LOOP AT ITAB.
      V_FILED5 = ITAB-F5. "to compare later
      V_TABIX = SY-TABIX. "used to delete if condition not matches
      READ TABLE ITAB WITH KEY F1 = ITAB-F1
                               F2 = ITAB-F2
                               F3 = ITAB-F3
                               F4 = ITAB-F4.
      IF SY-SUBRC = 0.
        IF ITAB-F5 <> V_FIELD5.
    *--both the records to be deleted,as Field5 is different.
          DELETE ITAB INDEX SY-TABIX. "deletes that record
          DELETE ITAB INDEX V_TABIX. "deletes the current record
        ENDIF.
      ENDIF.
    ENDLOOP.
    Message was edited by: Srikanth Kidambi
    added comments
    Message was edited by: Srikanth Kidambi

  • Update databse from internal table statement not using index

    Hi Guys,
    We are updating a databse table from a file. The file has a couple of fields which have data different from what the database has (non-primary fields :). We upload the file data into an internal table and then update the database table from internal table. At a time, internal table is supposed to have 10,000 records. I did SQL trace and found that the update statement is not making use of the databse index.
    Should not the update statement here be using the table index (for primary key)?
    Regards,
    Munish

    ... as often there are recommendations in this forum which makes me wonder, how people overestimate their knowledge!!!
    Updates and Deletes do of course use indexes, as can be seen in the SQL Trace (use explain).
    Inserts don't use indexes, because in many databases inserts are just done somewhere, But also with the INSERT, the primary key is the constraint for the uniqueness condition, duplicate keys are not allowed.
    Coming to the original question, what is you actually coding for the update?
    What is the table, which fields are in the internal table and what are the indexes?
    Siegfried

  • Can not insert or update [TABLE] from internal table in method

    I've faced a problem with OO abap. I've tried to insert into [ TABLE ] from internal table, but i've got error msg after i compiled.
    "An explicit work area is necessary in the OO context. Use "INSERT wa INTO [TABLE] itab""
    After  i changed to loop in work area and INSERT INTO  [TABLE] VALUES gw_data., everything is fine, can compile and run.
    This is error code.
      METHOD set_data_to_table.
        REFRESH gi_data.
        CLEAR gi_data.
        IF gi_file[] IS NOT INITIAL.
    * Set data for modify table
          LOOP AT gi_file INTO gw_file.
            MOVE-CORRESPONDING gw_file TO gw_data.
            me->conversion_input( EXPORTING im_vendor = gw_data-vendor
                                  CHANGING  ch_vendor = gw_data-vendor ).
            APPEND gw_data TO gi_data.
          ENDLOOP.
          INSERT [TABLE] FROM TABLE gi_data.
    *      LOOP AT gi_data INTO gw_data.
    *        INSERT INTO  [TABLE] VALUES gw_data.
    *        IF sy-subrc = 0.
    *          COMMIT WORK.
    *        ELSE.
    *          ROLLBACK WORK.
    *        ENDIF.
    *      ENDLOOP.
        ELSE.
          MESSAGE 'No data found' TYPE 'I'.
        ENDIF.
      ENDMETHOD.                    "set_data_to_table

    Hi Matthew,
    I think there is no difference in database insert between OO and non-OO.
    The correct syntax according to ECC600 online documentation is
    [Inserting Several Lines|http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/content.htm]
    To insert several lines into a database table, use the following:
    INSERT target FROM TABLE itab \[ACCEPTING DUPLICATE KEYS].
    This writes all lines of the internal table itabto the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.
    Whenever you want to insert more than one line into a database table, it is more efficient to work with an internal table than to insert the lines one by one.
    I think the syntax
    INSERT my_dbtable FROM TABLE gi_data.
    should work, your suggestion may lead to syntax error.
    Regards,
    Clemens

  • Fetch the values from internal table inside an internal table (urgent!!)

    data : BEGIN OF PITB2_ZLINFO occurs 0,
             BEGDA LIKE SY-DATUM,
             ENDDA LIKE SY-DATUM,
             PABRJ(4) TYPE N,                       "Payroll Year
             PABRP(2) TYPE N,                       "Pay. Period
             ZL LIKE PC2BF OCCURS 0,
           END OF PITB2_ZLINFO.
    I have a internal table like this,
    How to Fetch the values from internal table inside an internal table.
    Kindly Help me on this..
    Regards,
    Ram.

    Hi,
    Try this....
    Loop at PITB2_ZLINF0.
    Loop at PITB2_ZLINF0-ZL.
    endloop.
    Endloop.
    Thanks...
    Preetham S

  • Could not delete from specified table?

    hi all,
    i'm getting this error could not delete from specified table when i execute a delete on dbf file via JDBC-ODBC bridge, when i execute an update table command i get operation must use an updatable query, but i'm not updating the query returned from select statement.
    Does anyone have similar problem before??

    Hi,
    my code is below:
    try {     
    conn=DriverManager.getConnectio("jdbc:odbc:sui","","");
    stmt = conn.createStatement();     
    int r= stmt.executeUpdate("Update Alarms set ACK=True WHERE DT = { d '" + msgdate + "' } AND TM= '" + msgtime + "'");
    System.out.println(r+" records updated in Alarms ");
    stmt.close();
    conn.close();
    stmt=null;
    conn=null;
    catch (NullPointerException e) {System.out.println(e.getMessage());}
    catch (SQLException e) {System.out.println(e.getMessage());}
    I have an ODBC datasource called sui and a table called alarms, i need to write into the column Ack to true when DT equals msgdate and TM equals msgtime, the error returned is Operation must use an updatable query.
    I believe the SQL has no problem because there is no SQL syntax error and i'm not updating any resultset returned from select query.
    When i delete, i get could not delete from specified table. Anyone has any idea wh'at's wrong?

  • How to send data from internal table to the shared folder in ABAP

    Hi experts,
             My requirement is to transfer data from a file to shared folder. i just did reading data from a file to a internal table. Now i want to send this internal table data into a shared folder which is  "
    xxx\y\z....".
    I do not have any idea on how to send data from internal table to the shared folder path.
    can anybody please help me out how to do this?
    Thanks & Regards
    Sireesha.

    Where that folder is located, its on presentation server i.e. desktop or application server.
    If its on presentation server, use FM GUI_UPLOAD.
    If its on application server, then use DATASET functions. Have a look at below link.
    [File Handling in ABAP|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm]
    I hope it helps.
    Thanks,
    Vibha
    Please mark all the useful answers

  • Create XML file from internal table and vise a versa

    Hi Friends,
    I have requirement to create an XML string from internal table data and also read XML string data to internal table.
    Can anybody tell are there any Function Modules or methods existing for this?
    Thanks.
    Krishna Yerram.

    1. Write XSLT program. T.code XSLT . e.g. XSLT name "ZTRANS".
    2. Write ABAP program
    Which includes declaration of internal tables
    that you need "IT_DATA".
    Upload XML data to an internal table "IT_XML "
    use below statement to convert XML to internal table.
    Call transformation ZTRANS
    source XML IT_XML
    result IT_DATA.

Maybe you are looking for

  • How to get selected value from SelectOneChoice

    Hi, I'm facing a problem to get selected value from SelectOneChoice. I have valueChangeListener event on a (SelectOneChoice)item. After user makes a choice I want to store selected value in a bean property to pass it to a method. For example List ite

  • Stacked chart help in apex 4.0

    Hi All, I am working on a stacked chart.below is the query select  null link,range label,count(total) value1,Dept value2 from (select '0-10' as range,count(emp_id) total,Dept from table group by Dept union all select '10-20' as range,count(emp_id) to

  • Junk Mail filter can't handle high volume

    I use Mail.app at work/school. Unfortunately, my email address there is [email protected], and because it's so simple spammers have taken to sending spam that looks like it came from me. So every day I get dozens to hundreds of bounces from their spa

  • Hi i need to transfer from a disc drive to my imac some music files but i cannot work it out?

    hi, just purchased an i mac this week and trying to do as the man in the shop told me to.... we have an old laptop which is really slow and we would like to transfer data using the cd drive in the laptop to the imac, mainly cd's ie music i was told t

  • TDS deduction twice

    Hi all, when i am raising invoice tds is deducted , but when i am making payment then also the TDS has been deducted. How to resolve this error. that when TDS is deducted at the time of invoice , it should not be deducted at the time of payment posti