‎2008 Jul 30 8:36 AM
Hi Experts
I have one requirement to proceed for the following below by the managment.
need to create a u201Creportu201D to be executed in batch mode which will delete Command interface records from SAP.
There are two tables from which the data needs to be deleted:
1. ZINT_DATA
2. ZINT_MSGS
ZINT_DATA contains the actual data records from Command together with information about this data, e.g. processing status, date to which the data refers etc.
ZINT_MSGS contains messages which have been generated during the SAP processing of the data records.
Criteria for selecting records to be deleted are as follows:
1. ZINT_DATA
u2022 ZINT_DATA.CREATED_ON <= (Today u2013 30 Days)
u2022 ZINT_DATA.STATUS = u2018OKu2019
2. ZINT_MSGS
u2022 ZINT_MSGS.CREATED_ON <= (Today u2013 30 Days)
The report should log the number of records deleted from each table at End Of Run.
I would be thankful if anyone comment on how to create this report.
Regards
Piroz
Edited by: Piroz Eslam on Sep 19, 2008 8:36 AM
‎2008 Sep 19 7:18 AM
Hi Piroz,
Try this code,
TABLES: zint_data,
zint_msgs.
DATA: it_zint_data TYPE TABLE OF zint_data ,
it_zint_msgs TYPE TABLE OF zint_msgs.
DATA: v_date TYPE sy-datum,
v_lines type sy-index.
START-OF-SELECTION.
v_date = sy-datum - 30.
SELECT * FROM zint_data INTO TABLE it_zint_data WHERE CREATED_ON <= v_date and status = 'OK'.
if not it_zint_data[] is initial.
clear v_lines.
describe table it_zint_data lines v_lines.
delete zint_data from table it_zint_data.
write:/ 'No of entries deleted from table ZINT_DATA :' , v_lines.
endif.
SELECT * FROM zint_msgs INTO TABLE it_zint_msgs WHERE CREATED_ON <= v_date.
if not it_zint_msgs[] is initial.
clear v_lines.
describe table it_zint_msgs lines v_lines.
delete zint_msgs from table it_zint_msgs.
write:/ 'No of entries deleted from table ZINT_MSGS :' , v_lines.
endif.
Hope this helps
Thanks
Lakshman
‎2008 Sep 19 7:18 AM
Hi Piroz,
Try this code,
TABLES: zint_data,
zint_msgs.
DATA: it_zint_data TYPE TABLE OF zint_data ,
it_zint_msgs TYPE TABLE OF zint_msgs.
DATA: v_date TYPE sy-datum,
v_lines type sy-index.
START-OF-SELECTION.
v_date = sy-datum - 30.
SELECT * FROM zint_data INTO TABLE it_zint_data WHERE CREATED_ON <= v_date and status = 'OK'.
if not it_zint_data[] is initial.
clear v_lines.
describe table it_zint_data lines v_lines.
delete zint_data from table it_zint_data.
write:/ 'No of entries deleted from table ZINT_DATA :' , v_lines.
endif.
SELECT * FROM zint_msgs INTO TABLE it_zint_msgs WHERE CREATED_ON <= v_date.
if not it_zint_msgs[] is initial.
clear v_lines.
describe table it_zint_msgs lines v_lines.
delete zint_msgs from table it_zint_msgs.
write:/ 'No of entries deleted from table ZINT_MSGS :' , v_lines.
endif.
Hope this helps
Thanks
Lakshman