Skip to Content
author's profile photo Former Member
Former Member

loop

Loop at itab into wa

HERE if wa-field1 = some condition

I want to delete itab entry based on condition above

AND

goto next record in loop

Endloop.

How can I do this

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

10 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 05:44 AM

    Hi,

    Instead of looping try this:

    delete itab[] where field = <condition>.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 05:46 AM

    write the following code.

    write this in loop.

    delete <TABLE> index sy-tabix.

    Edited by: vamshi naini on Jun 18, 2008 11:17 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 18, 2008 at 05:48 AM

    hi,

    check this sample code.

    loop at it_ekko.

    if it_ekko-frgke = 'R' or ( it_ekko-bsart = 'UB' and it_ekko-frgke = ''

    ).

    else.

    delete table it_ekko.

    endif.

    endloop.

    this will delete all records from the internal table which satisfys that condition.

    reward if hlpful.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 18, 2008 at 05:49 AM

    Hi,

    U can use delete itab with a where clause,need not use a loop statement for this.

    ****Reward if useful

    Regards,

    Ruby.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 18, 2008 at 05:51 AM

    HI ,

    Try this..

    Loop at itab into wa .

    if wa-field1 = some condition .

    delete itab index sy-tabix.

    continue.

    Endif.

    Endloop.

    Regards,

    Sachin M M

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 05:51 AM

    Hi,

    loop at itab.

    if itab-field1 > 100.

    delete itab. " (or u can also use DELETE ITAB INDEX SY-TABIX).

    continue." It will continue the loop with out executing the below code.

    endif.

    endloop.

    Thanks,

    Ravi.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 05:51 AM

    Hi,

    Try the code written below your problem will be solved.

    Delete itab WITH TABLE KEY field1 = some condition.
    IF SY-SUBRC = 0.
      CONTINUE.
    ENDIF.

    Reward some points.

    Regards.

    Anomitro Guha

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 05:52 AM

    Hi,

    You should not use 'DELETE' statement inside LOOP.....ENDLOOP.

    It will give you Performance Issue. Give a Flag in the same internal Table. Then you can delete the records of the Internal Table when coming outside of the LOOP ...ENDLOOP.

    IF NOT s_matkl[] IS INITIAL.

    LOOP AT i_eina INTO wa_eina.

    l_index = sy-tabix.

    READ TABLE i_mara WITH

    KEY matnr = wa_eina-matnr TRANSPORTING NO FIELDS

    BINARY SEARCH.

    IF sy-subrc <> 0.

    wa_eina-flag = c_x.

    MODIFY i_eina FROM wa_eina INDEX l_index TRANSPORTING flag.

    ENDIF.

    ENDLOOP.

    *Filtering the values in I_EINA by Material Group

    DELETE i_eina WHERE flag EQ c_x.

    ENDIF.

    Regards,

    Viji.

    Edited by: VijayaLakshmi Krishnaswamy on Jun 18, 2008 7:54 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 18, 2008 at 06:01 AM

    Hi,

    you can do this in many ways:

    Deleting a Single Line

    To delete a line using its index, use the following statement:

    DELETE <itab> [ INDEX <idx> ].

    If you use the INDEX addition, the system deletes the line

    with the index <idx> from table <itab>,

    Deleting Several Lines

    To delete more than one line using the index, use the following statement:

    DELETE <itab> [ FROM <n1> ] [ TO <n 2> ] [ WHERE <condition> ].

    note:you can also do this by using key instead of index.

    Regards

    Adil

    Edited by: Syed Abdul Adil on Jun 18, 2008 8:01 AM

    Edited by: Syed Abdul Adil on Jun 18, 2008 8:02 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 06:08 AM

    Hi,

    You can use code below:

    
    delete itab where <field_name> = 'Condition'.
    
    

    Performance wise above code is good and try to filter out at select statement only.

    Thanks,

    Sriram Ponna.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.