‎2008 May 09 9:42 AM
Hi
Is it possible to delete an entry from the table if the table is non-editable ?
Thanks
chitra
‎2008 May 09 9:44 AM
‎2008 May 09 9:46 AM
it is a standard database table .
i want to delete it through a report .
‎2008 May 09 9:50 AM
Then write the code.
this is program which will delete the records based on comapany code.
check it and be careful.
*&----
*
*& Report ZTABDELE note 365304
*
*&----
*
*& Please replace XXXX - two times - with the name of the table *
*& to be deleted (in lines 30 and 31) *
*& *
*&----
*
REPORT ZTABDELE MESSAGE-ID ZMSG.
type-pools : abap.
TABLES : DD02L, T000.
DATA : BEGIN OF IT_UPLOAD OCCURS 0,
TAB_NAME LIKE DD03P-TABNAME,
KEY_FLD LIKE DD03P-FIELDNAME,
END OF IT_UPLOAD.
DATA BEGIN OF NTAB OCCURS 20.
INCLUDE STRUCTURE DNTAB.
DATA END OF NTAB.
DATA BEGIN OF X030L_TAB.
INCLUDE STRUCTURE X030L.
DATA END OF X030L_TAB.
DATA: BEGIN OF KEYFIELD OCCURS 20,
LINE LIKE DD03D-FIELDNAME,
END OF KEYFIELD.
DATA: TABLE LIKE DD02L-TABNAME,
TEXT LIKE DD03D-FIELDNAME,
TEXTLINE(40),
TEXTLINE2(40),
ANSWER,
NTSUBRC LIKE SY-SUBRC,
SUBRC LIKE SY-SUBRC.
data : g_string type string.
DATA : REC_CNT TYPE I.
DATA: it_opt LIKE rfc_db_opt OCCURS 0 WITH HEADER LINE.
field-symbols : HORIZONTAL_TAB.
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP.
PARAMETERS : CNT_REC TYPE I.
PARAMETERS : P_FILE LIKE sdokpath-pathname.
SELECTION-SCREEN END OF BLOCK BLK1.
*&----
*
*&At selection-screen *
*&----
*
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM select_file USING p_file.
*&----
*
*& start of selection *
*&----
*
START-OF-SELECTION.
PERFORM read_file.
NROWS = CNT_REC.
WRITE : /5 'Table Name', 30 'No of Records Deleted'.
LOOP AT IT_UPLOAD.
CLEAR : ifc.
REFRESH : ifc.
perform get_structure using IT_UPLOAD-tab_name .
CREATE DATA dy_table TYPE TABLE OF (IT_UPLOAD-tab_name).
UNASSIGN .
COMMIT WORK.
WRITE : /5 IT_UPLOAD-tab_name, 30 REC_CNT.
ENDIF.
ENDIF.
ENDDO.
ELSE.
ENDIF.
ENDIF.
ENDLOOP.
*&----
*
*& get_structure
*&----
*
form get_structure using p_table.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails = ref_table_des->components.
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform. "get_structure
*&----
*
*& Form select_file
*----
*
FORM select_file USING p_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = '*.TXT'
def_path = 'C:'
mask = ',.TXT,.*.'
mode = 'O'
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
WRITE:/ 'Error in Selecting :', p_file.
ENDIF.
ENDFORM. " select_file
*&----
*
*& Form read_file
*&----
*
FORM read_file .
open dataset p_file for input in text mode encoding non-unicode.
if sy-subrc <> 0.
message e000 with 'Error on input file read'.
endif.
do .
read dataset p_file into l_line.
if sy-subrc <> 0.
exit.
endif.
split l_line at cl_abap_char_utilities=>horizontal_tab
into it_upload-tab_name it_upload-key_fld.
LEN = STRLEN( it_upload-key_fld ).
IF LEN > 5.
LEN = LEN - 1.
it_upload-key_fld = it_upload-key_fld(LEN).
endif.
append it_upload.
CLEAR LEN.
enddo.
ENDFORM. " read_file
Regards,
Madan.
Edited by: madan mohan reddy on May 9, 2008 2:20 PM
‎2008 May 09 9:54 AM
hi Jaya
check whether the table view maitainance is set as Display/maitainance allowed with restrictions or simple allowed.if so you can delete if none of the above mentioned options are not set.
you cannot delete.
Reward if help full.
Regards
Lakshman
‎2008 May 09 9:45 AM
Hi,
Ya it is possible to delete an entry from the table in display mode.
by going into debugging mode.
‎2008 May 09 9:46 AM
‎2008 May 09 10:43 AM
Yes it is possible
go to SE16N-->put table name and type &SAP_EDIT (where you type tcode ) and hit enter.
this way you can delete table entries
‎2008 Jul 22 8:37 AM
Hi,
I tried to do that in our testing box, the entry was deleted and no longer appear on t-cd VB03. However, the entry is still existing on the standard table.
If you don't mind,is it safe to use this kind of method?
I have the same case, i need to delete thousand entries on a standard table. Are there any other way a side from this and through modifying the code?.
Would appreciate your inputs. Thanks in advance.
‎2008 Jul 22 8:49 AM
When will people learn?!
YOU SHOULD NOT DIRECTLY DELETE ENTRIES FROM STANDARD TABLES.
Do any of you suggesting to do this fully understand the implications?
What will you do when the SAP system you are deleting from all goes wrong because it's data is corrupt?
You should never need to just delete records from a standard table - you should only ever need to get rid of the actual master data or transactional data object that those records relate to. So if you want to delete an entry from VBAK for instance you delete the sales order.
Go and google for referential integrity for some further reading about how you can break your SAP system.