04-26-2006 8:38 AM
Dear All,
I need to delete ALL THE entries in the table marc that contains entries in the mara table.
Pls. let me know how to code this.
Thanks in Advance,
CR
04-26-2006 8:43 AM
Hi,
select * from marc
into table it_marc.
if sy-subrc = 0.
select * from mara
into it_mara
for all entries in it_marc
where matnr = it_marc-matnr.
if sy-subrc = 0.
<b>delete marc from it_mara.</b>
endif.
endif.
Regards
vijay
04-26-2006 8:42 AM
Hello KC,
It is not correct to delete the table entries in MARC directly as u are creating inconsistency in the SAP database table. The entries in MARC should be deleted through std mechanism and not otherwise.
However if u want to still go ahead and delete then u need to read table MARA and for each entry in MARA DELETE entries from MARC using where clause.
BUT
04-26-2006 8:43 AM
Hi,
select * from marc
into table it_marc.
if sy-subrc = 0.
select * from mara
into it_mara
for all entries in it_marc
where matnr = it_marc-matnr.
if sy-subrc = 0.
<b>delete marc from it_mara.</b>
endif.
endif.
Regards
vijay
04-26-2006 8:45 AM
Small correction to the issue.
Please delete log entries from table DBTABLOG related to KONP and YMTOL_I696_MAINF tables.
Kindly let me know.
Thanks a lot,
Ranjan
04-26-2006 8:50 AM
data : begin of itab occurs 0.
include structure DBTABLOG.
data: end of itab.
select * from DBTABLOG into table itab where tabname = 'KONP' or TABNAME = 'YMTOL_I696_MAINF'.
delete DBTABLOG from table itab .
04-26-2006 8:52 AM
Hi,
select * from DBTABLOG
into table it_dblog
where TABNAME = 'KONP'
or TABNAME = 'YMTOL_I696_MAINF'.
if sy-subrc = 0.
<b>delete DBTABLOG from table it_dblog.</b>
endif.
Regards
vijay
04-26-2006 8:58 AM
Thanks a lot Vijay,
Last question is, I need to select the table name from the selection screen (entered by user). i.e., the user can enter either KONP or 'YMTOL_I696_MAINF'.
Kindly let me know how to do this..
Thanks,
CR
04-26-2006 9:01 AM
Hi,
I think u'll enter it in a parameter.
then change your where condition as
select * from DBTABLOG
into table it_DBTABLOG
where TABNAME = p_tabname. " table name
if sy-subrc = 0.
DELETE DBTABLOG FROM TABLE IT_DBTABLOG.
endif.
Regards,
GSR.
04-26-2006 9:04 AM
[code]selet-options begin of block b1 with frame title text-001.
selet-options : s_tabnm for datablog-tabname.
selet-options end of block b1
select * from DBTABLOG into table itab where tabname in <b>s_tabname.</b>
if sy-subrc = 0.
delete DBTABLOG from table itab .
endif.
pls reward for helpful answers and close the thread if solved
Message was edited by: Sekhar
Message was edited by: Sekhar
04-26-2006 9:22 AM
Hi,
REPORT ZTEST_Delete MESSAGE-ID ZZ .
TABLES: DD02L.
data: tablename type dd02l-tabname.
DATA: IT_DBLOG LIKE DBTABLOG OCCURS 0 WITH HEADER LINE.
SELECT-OPTIONS: S_TABLE FOR DD02L-TABNAME NO INTERVALS.
AT SELECTION-SCREEN.
LOOP AT S_TABLE.
tablename = S_TABLE-LOW.
IF tablename <> 'KONP' and tablename <> 'YMTOL_I696_MAINF'.
MESSAGE E000 WITH 'enter valid tab name'.
ENDIF.
ENDLOOP.
SELECT * FROM DBTABLOG
INTO TABLE IT_DBLOG
WHERE TABNAME IN S_TABLE.
IF SY-SUBRC = 0.
DELETE DBTABLOG FROM TABLE IT_DBLOG.
ENDIF.
Regards
vijay
04-26-2006 10:29 AM
04-26-2006 6:03 PM
WARNING! Deleting any entries from SAP tables directly is likely to fracture database integrity and highly likely to invalidate your support contract!
04-26-2006 8:46 AM
Hi,
Write a Join on MARA and MARC into IT_MARA.
Now write
DELETE MARC FROM TABLE IT_MARA.
********************************************
Simply write a select statement on DBTABLOG as
select * from DBTABLOG
into table it_DBTABLOG
where TABNAME = 'KONP' OR
TABNAME = 'YMTOL_I696_MAINF'.
DELETE DBTABLOG FROM TABLE IT_DBTABLOG.
Regards,
GSR.
04-26-2006 8:46 AM
small correction to vijays code
delete marc from <b>table</b> it_mara.