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

is there any other way to do it?

hi

is there any other way to do it? if yes please tell me how...

LOOP AT itab.

SELECT SINGLE lgort INTO lv_lgort

FROM zbas

WHERE werks EQ itab-werks

AND lgort EQ itab-lgort.

IF sy-subrc NE 0.

DELETE itab.

ENDIF.

ENDLOOP.

this creates the perforamnce issue that we can not use select inside loop.plz suggest me the other way to do it..

i m tryin to do it this way .. will it work

SELECT SINGLE lgort INTO lv_lgort

FROM zbas

WHERE werks EQ itab-werks

AND lgort EQ itab-lgort.

LOOP AT itab.

IF lv_lgort NE itab-lgort.

DELETE itab.

ENDIF.

ENDLOOP.

thnx

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    Posted on Feb 27, 2007 at 07:56 AM

    Hi,

    Try this

    DATA: BEGIN OF ITAB occurs 0,
           werks LIEK zbas-werks,
           lgort LIEK zbas-lgort,
           END OF ITAB.
    IF NOT itab[] IS INITIAL.
    SELECT werks lgort INTO TABLE i_lgort
                 FROM zbas
                 FOR ALL ENTRIES in itab
                 WHERE werks EQ itab-werks
                 AND lgort EQ itab-lgort.
    ENDIF.
    
    LOOP AT itab.
    Read table i_lgort WITH KEY werks = itab-werks
                                lgort = itab-lgort.
    if sy-subrc NE 0.
     DELETE itab.
    ENDIF.
    ENDLOOP.
    

    Reward points if this olvesur problem.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 27, 2007 at 07:55 AM

    U can use FOR ALL ENTRIES instead of using SELECT in a LOOP.

    Regards

    Gopi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 07:55 AM

    TAKE A TABLE LIKE ITAB SAY ITAB1 AND TTABIX LIKE SY-TABIX VARIABLE.

    SELECT lgort INTO TABLE ITAB1

    FROM zbas

    FOR ALL ENTRIES IN ITAB

    WHERE werks EQ itab-werks

    AND lgort EQ itab-lgort.

    LOOP AT ITAB.

    TTABIX = SY-TABIX.

    READ TABLE ITAB1 WITH KEY werks = itab-werks lgort = itab-lgort.

    IF SY-SUBRC NE 0.

    DELETE ITAB INDEX TTABIX.

    ENDIF.

    ENDLOOP.

    REGARDS

    SHIBA DUTTA

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 07:59 AM

    Try this:

    SELECT lgort from zbas INTO CORRESPONDING FIELDS OF TABLE

    ltab_lgort FOR ALL ENTRIES IN itab

    WHERE werks EQ itab-werks

    AND lgort EQ itab-lgort.

    **Now itab_igort will contain all the matching entries from itab.

    **compare itab and itab_gort..

    Loop at itab.

    READ TABLE itab_gort

    WITH KEY werks = itab_werks

    TRANSPORTING NO FIELDS.

    if sy-subrc ne 0.

    delete itab[].

    endif.

    endloop.

    Hope this helps.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 08:00 AM

    HI NEHA,

    WRITE CODE IN THIS WAY .

    CREATE INTERNAL TAB IT_TAB .

    THIS TAB CONTAIL ONLY ONE FIELD lgort

    THEN

    SELECT lgort INTO TABLE IT_TAB

    FROM zbas

    FOR ALL ENTRIES IN ITAB

    WHERE werks EQ itab-werks

    AND lgort EQ itab-lgort.

    THEN IT_TAB CONTAIN ALL MACHING RECORDS

    NOW DELETE ALL RECORDS THOSE NOT IN IT_TAB BY COMPAING TWO INTERNAL TABLE IT_TAB ITAB

    MUKESH AGGARWAL

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 08:05 AM

    but on what condition u want to delete the entries in itab ?

    only storage location or any combination of plant and lgort + matnr ??

    You need to fix this thing up .

    1.see the sol'n is first do a select all the entries for the criteria into a internal table say jtab .

    and

    2. loop at itab .

    read table jtab with key <b>jtab-f1 = itab-f1 }

    jtab-f2 = itab-f2.</b> "if applies

    if sy-subrc eq 0 .

    delete the entry where <condition>.

    endif.

    endloop.

    //

    ur option :

    SELECT SINGLE lgort INTO lv_lgort

    FROM zbas

    WHERE werks EQ itab-werks

    AND lgort EQ itab-lgort.

    LOOP AT itab.

    IF lv_lgort NE itab-lgort.

    DELETE itab.

    ENDIF.

    ENDLOOP.

    the order is not good for this scenario.

    vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 08:24 AM

    SELECT key_field1

    key_field2

    .............

    lgort INTO table it_lv_lgort

    FROM zbas

    WHERE werks EQ itab-werks

    AND lgort EQ itab-lgort.

    if not it_lv_lgort[] is initial.

    LOOP AT itab.

    read it_lv_lgort with key_fiel_1 = itab-key-fiel_1...

    DELETE itab.

    ENDLOOP.

    endif.

    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.