on 12-08-2008 5:02 AM
Hi All,
My Requirement is:--
I need to take workitem from table SWWWIHEAD using date and time range.
Suppose user has given 20 Hours on selection screen and now the system time is 7 AM of
8th December.
Here I need to take the workitems created within last 20 Hours.
So 20 hours back means, 11 AM of 7th December.
Previous Date like 7th December, I can calculate, but how to take Workitems
in the period:-- 11 AM of 7 Dec to 7 AM of 8 December.
because 7 am - 20 hours = 11 am of previous day
If user give 24 houus on selection screen,
then 7 am - 24 hours = 7 am of previous day
Now if I write select query like below, I did not get any record,
SELECT * FROM swwwihead INTO TABLE int_swwwihead_n
WHERE wi_type = 'W' AND
wi_rh_task IN r_task AND
wi_cd >= wf_date_low_n AND
wi_cd <= wf_date_hi_n AND
wi_ct >= wf_time_low_n AND
wi_ct <= wf_time_hi_n AND
wi_stat IN r_status
So pls guide me how to take relevant records based on both date & time.
Rishi
Hello,
There are a number of possible solutions. I like this one:
SELECT * FROM swwwihead INTO TABLE int_swwwihead_n
WHERE wi_type = 'W' AND
wi_rh_task IN r_task AND
wi_stat IN r_status AND
(
(wi_cd = wf_date_low_n AND
wi_ct >= wf_time_low_n ) OR
(wi_cd = wf_date_hi_n AND
wi_ct <= wf_time_hi_n ) OR
(wi_cd > wf_date_low_n AND
wi_cd < wf_date_hi_n )
)
It's more generic and doesn't assume the time difference is less than 48 hours.
Note that I haven't tested it, that is of course up to you. Be especially careful to test what happens when the user fills in midnight.
regards
Rick Bakker
Hanabi Technology
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try the following query.
SELECT * FROM swwwihead
INTO TABLE int_swwwihead_n
WHERE wi_type = 'W' AND
wi_rh_task IN r_task AND
wi_stat IN r_status AND
( ( wi_cd = wf_date_low_n AND wi_ct >= wf_time_low_n ) OR ( wi_cd = wf_date_hi_n AND wi_ct <= wf_time_hi_n ) ).
there is some modification in the WHERE clause.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rishi,
Instead of giving greater than and less than use Ranges.
create a range field of type
data: r_crtdate TYPE RANGE OF swwwihead-wi_cd,
r_crttime TYPE RANGE OF swwwihead-wi_ct.
data: wa_crtdate LIKE LINE OF r_crtdate,
wa_crttime LIKE LINE OF r_crttime.
Fill the range variables r_crtdate and r_crttime with low(Previous Date/Time) and high(current Date/Time) value and option as 'BT' (Between)
SELECT * FROM swwwihead INTO TABLE int_swwwihead_n
WHERE wi_type = 'W' AND
wi_rh_task IN r_task AND
wi_cd IN r_crttime AND
wi_ct IN AND
wi_stat IN r_status
This will work.
Please let me know if u have any other issues.
Regards,
Gautham Paspala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.