‎2007 Jul 06 8:00 PM
I have Material Number in an internal table and not material type.i want to delete all the material Number from the table whose material type not equal to 'ZFRT'.How i can i do that? Kindly help me.
‎2007 Jul 06 8:05 PM
Well, it would be easier and better to have Material Type within the internal table if you have the chance to do that, or even you could do this condition when selecting the materials from the database into the internal table, but if you truely have no other option, then i guess you can do this.
data: xmara type mara
loop at itab.
select single * from mara into xmara
where matnr = itab-matnr
and mtart = 'ZFRT'.
if sy-subrc <> 0.
delete itab.
continue.
endif.
endloop.REgards,
Rich Heilman
‎2007 Jul 06 8:05 PM
Well, it would be easier and better to have Material Type within the internal table if you have the chance to do that, or even you could do this condition when selecting the materials from the database into the internal table, but if you truely have no other option, then i guess you can do this.
data: xmara type mara
loop at itab.
select single * from mara into xmara
where matnr = itab-matnr
and mtart = 'ZFRT'.
if sy-subrc <> 0.
delete itab.
continue.
endif.
endloop.REgards,
Rich Heilman
‎2007 Jul 06 8:53 PM
‎2007 Jul 06 8:59 PM
Hi,
If you have material number in it_itab, then
TYPES : BEGIN OF x_mara,
matnr TYPE matnr,
mtart TYPE mtart,
END OF x_mara.
DATA : it_mara TYPE TABLE OF x_mara.
SELECT matnr mtart
FROM mara
INTO TABLE it_mara
FOR ALL ENTRIES IN it_itab
WHERE matnr = it_itab-matnr
AND mtart = 'ZFRT'.
IF sy-subrc = 0.
DELETE it_itab FROM it_mara.
ELSE.
REFRESH : it_mara.
ENDIF.
Reward points if the answer is helpful.
Regards,
Mukul
‎2007 Jul 06 9:02 PM
Hi,
If you have material number in it_itab, then
TYPES : BEGIN OF x_mara,
matnr TYPE matnr,
mtart TYPE mtart,
END OF x_mara.
DATA : it_mara TYPE TABLE OF x_mara.
SELECT matnr mtart
FROM mara
INTO TABLE it_mara
FOR ALL ENTRIES IN it_itab
WHERE matnr = it_itab-matnr
AND mtart = 'ZFRT'.
IF sy-subrc = 0.
DELETE it_itab FROM it_mara.
ELSE.
REFRESH : it_mara.
ENDIF.
Reward points if the answer is helpful.
Regards,
Mukul