Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

deleting a table.

Former Member
0 Likes
783

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..

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..

5 REPLIES 5
Read only

former_member156446
Active Contributor
0 Likes
757
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.
Read only

Former Member
0 Likes
757

I think you want to first check the 0 entry in field of table and then delete entries of other table.Is it??

Read only

Former Member
0 Likes
757

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..

Read only

Former Member
0 Likes
757

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

Read only

Former Member
0 Likes
757

Hi, try like this,

IF RSBKREQUEST-linestransferred = 0.

DELETE FROM /BIC/OHFGL_UN_2.

ENDIF.