‎2009 Oct 29 6:30 AM
Hi guriji's.
There are two table t_itab1 and t_itab2. I want delete the whole row based on matnr which is in both table then pirnt the t_itab2 table output.
for this i have written one query which is properly not working.
LOOP AT T_ITAB2.
IF T_ITAB1-MATNR = T_ITAB2-MATNR .
SUM = SY-TABIX.
DELETE T_ITAB2 INDEX SUM.
ENDIF.
ENDLOOP.
plz tell me what is the problem.
Thanks.
‎2009 Oct 29 6:35 AM
Hi,
Use read to select the matnr line from other table
LOOP AT T_ITAB2 into fs_itab2.
read table it_itab1 into fs_itab1 with key matnr eq fs_itab2-matnr.
if sy-subrc EQ 0.
DELETE T_ITAB2 from fs_itab2..
endif.
ENDLOOP.
‎2009 Oct 29 6:35 AM
Hi,
Use read to select the matnr line from other table
LOOP AT T_ITAB2 into fs_itab2.
read table it_itab1 into fs_itab1 with key matnr eq fs_itab2-matnr.
if sy-subrc EQ 0.
DELETE T_ITAB2 from fs_itab2..
endif.
ENDLOOP.
‎2009 Oct 29 6:37 AM
Hello
Try this:
LOOP AT T_ITAB2.
READ TABLE T_ITAB1 WITH KEY MATNR = T_ITAB2-MATNR.
IF SY-SUBRC = 0.
DELETE T_ITAB2.
ENDIF.
ENDLOOP.
‎2009 Oct 29 6:38 AM
You are not rading the values from internal table T_ITAB1
Use READ statement after the loop statement
READ table t_tab1 with key matnr eq t_tab1-matnr
Regards,
lakshman.
Edited by: Lakshman N on Oct 29, 2009 7:40 AM
‎2009 Oct 29 6:38 AM
Try this:
LOOP AT T_ITAB2.
READ TABLE T_ITAB1 WITH KEY MATNR = T_TAB2-MATNR.
IF SY-SUBRC = 0.
DELETE T_ITAB2 .
ENDIF.
ENDLOOP.
‎2009 Oct 29 6:56 AM
HI,
The problem is that you are not reading the table T_ITAB1 before deletion. Try the code below.
LOOP AT T_ITAB2.
READ TABLE T_ITAB1 WITH KEY MATNR = T_ITAB2-MATNR.
IF SY-SUBRC = 0.
DELETE T_ITAB2.
ENDIF.
ENDLOOP.
‎2009 Oct 29 7:04 AM
Hi Sachin,
Try this way.
Thanks
Venkat.O
LOOP AT t_itab1."Loop t_itab1 first
LOOP AT t_itab2 WHERE matnr = t_itab1-matnr."Check matnr in t_itab2 based on t_itab1 matnr.
"If you find matnr in t_itab2. You can delete using sy-tabix.
"Sy-tabix gives the row number of the matnr found in t_itab2.
DELETE t_itab2 INDEX sy-tabix.
ENDLOOP.
ENDLOOP.