Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Delete modify in itab

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

DELETE from zapolp22 where date = lv_date .

Thanks,

Durai.V

5 REPLIES 5

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

DELETE from zapolp22 where date = lv_date .

Thanks,

Durai.V

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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