‎2008 Mar 31 3:34 PM
Hi All,
I had posted the query for getting weekend dates if an user enters a date range . Most of them had answerded it . Next I wanted ( Cheques, invoices, amount) data in those ranges, Mr Srinivas gurram Reddy had given the solution for it but Iam not getting the data properly.
below is the code
TABLES: PAYR.
DATA: v_RWBTR1(20) TYPE C,
v_RWBTR2(20) TYPE C,
v_RWBTR3(20) TYPE C,
v_RWBTR4(20) TYPE C,
v_count1(20) TYPE C,
v_count2(20) TYPE C,
v_count3(20) TYPE C,
v_count4(20) TYPE C.
DATA IT_PAYR LIKE PAYR OCCURS 100 WITH HEADER LINE.
DATA: wk_dow TYPE C,
wk_days TYPE i.
DATA: WK1 LIKE SY-DATUM.
DATA: PD LIKE SY-DATUM.
RANGES: r_weekend FOR sy-datum.
SELECT-OPTIONS:
p_dates FOR sy-datum.
START-OF-SELECTION.
WHILE p_dates-low LE p_dates-high.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = p_dates-low
IMPORTING
day = wk_dow.
IF WK_DOW = '1'.
WK1 = P_DATES-LOW.
ENDIF.
IF wk_dow = '6'.
* OR wk_dow = '7' .
r_weekend = 'IEQ'.
r_weekend-low = p_dates-low.
APPEND r_weekend.
* WRITE:/ p_dates-low.
r_date1-sign = 'I'.
r_date1-option = 'BT'.
r_date1-low = p_dates-low - 6.
r_date1-high = p_dates-low .
append r_date1.
clear r_date1.
CLEAR: v_RWBTR1,
v_count1.
SELECT * FROM PAYR WHERE ZALDT in R_DATE1.
MOVE-CORRESPONDING PAYR TO IT_PAYR.
APPEND IT_PAYR.
ENDSELECT.
SORT IT_PAYR BY ZALDT.
LOOP AT IT_PAYR.
v_RWBTR1 = v_RWBTR1 + it_payr-RWBTR.
v_count1 = v_count1 + 1.
ENDLOOP.
WRITE:/ P_DATES-LOW, V_COUNT1, V_RWBTR1.
ENDIF.
p_dates-low = p_dates-low + 1.
If iam giving the range (the range can be from 01/01/2008 to 12/31/2008.) as 0401/2008 to 04/30/2008 for the 1st record I get the weekend date as 04/05/2008 and the data like invoices, cheques are getting calculated for the range 03/30/2008 to 04/05/2008 and coming properly.
For the 2nd record or 2nd time Iam getting weekend data properly, but data for cheques and cheque amount are getting calculated for the range 03/30/2008 to 04/12/2008 * the correct range is 04/06/2008 to 04/12/2008 *.
The problem I think is with r_date1 , Can anyone please help me to get the desired results.
Thanks in Advance.
Regards,
Dan
Edited by: daniel reaves on Mar 31, 2008 4:35 PM
‎2008 Mar 31 3:56 PM
Why are you using r_date1?
Of course is bringing dates from 03/30 to 04/12, because r_date1 has both conditions, if you only want to select that weekend range change
r_date1-sign = 'I'.
r_date1-option = 'BT'.
r_date1-low = p_dates-low - 6.
r_date1-high = p_dates-low .
append r_date1.
clear r_date1.
to
refresh r_date1.
r_date1-sign = 'I'.
r_date1-option = 'BT'.
r_date1-low = p_dates-low - 6.
r_date1-high = p_dates-low .
append r_date1.
clear r_date1.