06-26-2008 5:05 AM
hi,
i am not able to delete data from internal table from a
date to date as 20.05.2006 to 25.05.2006
plz give me information for this
i used it by selection screen
SELECT-OPTIONS: s_ordid FOR zapolp22-ordid,
s_matnr FOR zapolp22-matnr,
s_locto FOR zapolp22-locto.
PARAMETERS: p_days TYPE i.
data: lv_date type DATS.
SELECT mandt
ordid
schedid
matnr
locto
lfmng
lfdat
locfr
rqmng
rqdat
prckz
blkstk
oppdelqty
zzapologmod
zzflagurgent
zzapottype
zzndays_l_time
FROM zapolp22 INTO TABLE lt_output
WHERE ordid IN s_ordid AND
matnr IN s_matnr AND
locto IN s_locto.
lv_date = sy-datum - p_days.
DELETE zapolp22 FROM lt_output.
IF sy-subrc = 0.
WRITE:/ 'Data Deleted'.
endif.
plz tell me where i can declare the lv_date in programm that it can delete data according to date to date.
thanks jayant
06-26-2008 5:11 AM
06-26-2008 5:10 AM
Hi,
SELECT-OPTIONS: s_ordid FOR zapolp22-ordid,
s_matnr FOR zapolp22-matnr,
s_locto FOR zapolp22-locto.
PARAMETERS: p_days TYPE i.
data: lv_date type sy-datum. " Changed
SELECT mandt
ordid
schedid
matnr
locto
lfmng
lfdat
locfr
rqmng
rqdat
prckz
blkstk
oppdelqty
zzapologmod
zzflagurgent
zzapottype
zzndays_l_time
FROM zapolp22 INTO TABLE lt_output
WHERE ordid IN s_ordid AND
matnr IN s_matnr AND
locto IN s_locto.
lv_date = sy-datum - p_days.
DELETE zapolp22 FROM lt_output.
Commit work "Add this.
IF sy-subrc = 0.
WRITE:/ 'Data Deleted'.
endif.
Thanks
VIkranth
06-26-2008 5:11 AM
06-26-2008 5:22 AM
1) Build a date range.
ranges: r_date for sy-datum.
r_date-sign = 'I'.
r_date-option = 'BT'.
r_date-low = sy-datum - p_days.
r_date-high = sy-datum.
append r_date.
Then delete the data from the table
delete itab where date in r_date.
2) In order to delete data from databse table using your internal table thenm the structiure of internal table should be same as that of database table.
lt_output structure should be same as that of "zapolp22".
Only move those records in lt_output which lies in the date range.
3) In order to achieve it, first build a date range as suggested in step1 then in the where clause just put additional clause as
WHERE ordid IN s_ordid AND
matnr IN s_matnr AND
locto IN s_locto AND
<date> in r_date.
Reward if useful.
06-26-2008 5:29 AM
Hi,
If you Want to Delete Data From Intrenal table Then Use This Statement
Delete table it_output from wa_output where date = lv_date.
Let me know if any problem.
06-26-2008 5:40 AM
Hi,
Why don't we put the date in select query itself and build a range table for it.
ranges: r_date for sy-datum.
lv_date = sy-datum - p_days.
r_date-sign = 'I'.
r_date-option = 'BT'.
r_date-low = lv_date.
r_date-high = sy-datum.
append r_date.
SELECT mandt
ordid
schedid
matnr
locto
lfmng
lfdat
locfr
rqmng
rqdat
prckz
blkstk
oppdelqty
zzapologmod
zzflagurgent
zzapottype
zzndays_l_time
FROM zapolp22 INTO TABLE lt_output
WHERE ordid IN s_ordid AND
matnr IN s_matnr AND
locto IN s_locto
AND lfdate IN r_date.
IF sy-subrc = 0.
DELETE zapolp22 FROM TABLE lt_output.
IF sy-subrc = 0.
MESSAGE i029 WITH sy-dbcnt text-002 . " Records Deleted
ENDIF.
ENDIF.
This will surely help you.
Plz reward if useful.
Thanks,
Dhanashri.
Edited by: Dhanashri Pawar on Jun 26, 2008 6:41 AM