2007 Feb 27 7:48 AM
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
2007 Feb 27 7: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.
2007 Feb 27 7:55 AM
U can use FOR ALL ENTRIES instead of using SELECT in a LOOP.
Regards
Gopi
2007 Feb 27 7: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
2007 Feb 27 7: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.
2007 Feb 27 7: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.
2007 Feb 27 8: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
2007 Feb 27 8: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
2007 Feb 27 8: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.