09-18-2008 9:01 AM
Hello
I'm using SD pricing condition table A004 and have f.ex. three condition records. Each record consists for a material with a valid from - valid to date.
example:
matnr: 312, datab: 01.01.2008, datbi: 15.01.2008
matnr: 312, datab: 16.01.2008, datbi: 31.01.2008
matnr: 312, datab: 01.02.2008, datbi: 31.12.2008
I would like to create a select statement to get all records within a given period.
In this case I would like to know all existing records within January 2008:
h_datab = 01.01.2008
h_datbi = 31.01.2008
SELECT knumh INTO TABLE t_knumh FROM A004
WHERE kappl = 'V'
AND kschl = kschl
AND matnr = matnr
AND datbi BETWEEN h_datab AND h_datbi
AND datab BETWEEN h_datab AND h_datbi
=> I also tried GT, LE etc.
Any ideas ?
thanks
09-18-2008 9:29 AM
I think that it's sufficient to test the beginnig date; you are interested in all prices valid in a given period so the pricing started in that period.
I'll do in this way, but I don't know what you really need.
h_datab = 01.01.2008
h_datbi = 31.01.2008
SELECT knumh INTO TABLE t_knumh FROM A004
WHERE kappl = 'V'
AND kschl = kschl
AND matnr = matnr
AND datab >= h_datab
AND datab <= h_datbi.
Hope this helps,
Regards
09-18-2008 9:31 AM
Hi,
You can try something like this:
assuming your db table has each a "valid from" and "valid to" field
select * from dbtab into inttab
(with the required select options but no restriction to the dates)
sort inttab by primary key fields
delete inttab
where ( valid_from > low_date "01.01.2008" OR valid_to < high_date "31.01.2008" ).
Kind Regards
Edited by: Raymond Friston on Sep 18, 2008 10:33 AM
09-18-2008 11:05 AM
great - I used following statement and it worked fine.
SELECT knumh INTO TABLE t_knumh FROM A004
WHERE kappl = 'V'
AND kschl = kschl
AND matnr = matnr
AND datbi >= h_datab
AND datbi <= i_datbi.
thanks a lot.