*Declare local Range:
Data:LR_date type range of sy-datum,
Ls_date like line of lr_date,
Lv_lowdate type sy-datum,
lv_highdate type sy-datum.
*Get the last posting date
selectmax( businessdaydate ) from ztran_balchk_log into lv_highdate. " this will affect the performance
*now you know the last posting data(lv_highdate).
Lv_lowdate = you have last post date(lv_highdate) – 6 months.
* it should delete last 6 months data .
Ls_date-low = Lv_lowdate.
Ls_date-high = lv_highdate.
Ls_date-option = ‘BT’.
Ls_date-sign = ‘I’.
Append Ls_date to lr_date.
* now get the six months data from ztable:
Select * from ztable into itab where business datein lr_date.
If sy-subrc is initial.
DELETE TABLE ztable from itabl.
If sy-subrc is initial.
Write: ‘success’.
endif.
endif.