2008 Apr 16 11:06 PM
Hi Gurus!
I need to write a select query such that if table-field = 0 , then go delete table.
ex :
RSBKREQUEST-linestransferred = 0.
then delete the table /BIC/OHFGL_UN_2.
thx in advance..
I think you want to first check the 0 entry in field of table and then delete entries of other table.Is it??
2008 Apr 16 11:09 PM
data: begin of itab.
include structure URTABLENAME.
data: end if itab.
select * from URTABLENAME
into table itab.
if sy-subrc eq 0.
delete table URTABLENAME.
endif.
if not itab[] is intial.
delete itab where field eq 0.
modify URTABLENAME by itab.
endif.
2008 Apr 17 5:57 AM
I think you want to first check the 0 entry in field of table and then delete entries of other table.Is it??
2008 Apr 17 6:19 AM
Hi Sandeep,
Call all the fields in the select query to itab and make a conditon to delecte the fields display 0.
Have this sample code for your guidance.
SELECT MCHBMATNR MCHBWERKS MCHBLGORT MCHBCHARG MCHBCLABS MCHBCINSM MCHB~CSPEM
MAKT~MAKTG
T001LLGOBE T001LLIFNR
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM MCHB
INNER JOIN MCH1
ON MCHBMATNR = MCH1MATNR AND MCHBCHARG = MCH1CHARG
INNER JOIN MAKT
ON MCHBMATNR = MAKTMATNR
INNER JOIN T001L
ON MCHBWERKS = T001LWERKS AND MCHBLGORT = T001LLGORT
WHERE MCHB~MATNR IN MATERIAL
AND MCHB~WERKS IN PLANT
AND MCH1~LVORM = ''.
LOOP AT ITAB.
ITAB-TOTAL = ITAB-CLABS + ITAB-CINSM + ITAB-CSPEM.
IF ITAB-TOTAL = 0.
DELETE ITAB.
MODIFY ITAB.
ENDIF.
ENDLOOP.
Reward if its useful..
2008 Apr 17 6:22 AM
hi,
there are two ways,
this affets ur db table.
1.delete dbtable where tab-field eq 0.
this affect internal table only
2.select * into itab
from table.
delete from itab where itab-field eq 0.
regards,
priya
Edited by: Banupriya R on Apr 17, 2008 7:22 AM
2008 Apr 17 7:10 AM
Hi, try like this,
IF RSBKREQUEST-linestransferred = 0.
DELETE FROM /BIC/OHFGL_UN_2.
ENDIF.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |