Skip to Content
0
Former Member
Apr 01, 2008 at 01:29 PM

Summing the values( #of cheques, Amount) based on month for the given date

25 Views

Hi all,

I have been doing a report to get Weekend dates from range of dates and based on that to get the values of # of cheques, amount of cheques in that range. I have been successful in getting the data for it.

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.Similarly I get for rest of the records.

Now the query is I need to calculate the sum of # of cheques, sum of the cheque amount based on month

If the input is 03/20/2008 to 04/15/2008

The desired ouput should be :

weekend date Number of cheques Cheque amount

03/22/2008 5 2345

03/29/2008 12 1567

'Total for march' 17 3912

04/05/2008 4 1234

04/12/2008 1 4321

'total for april 5 5555

Similarly for rest of the months, If there are other months in the range. The problem is Iam not able to get the Total for a particular month.

Below is the code:


TABLES: PAYR.
ranges : r_date1 for sy-datum .

TYPES: BEGIN OF EXTRACTREC,
       WEEKEND LIKE SY-DATUM,
       DATE(40)           TYPE C,
       INVOICES(40)       TYPE C,
       MANUALS(40)        TYPE C,
       CHECKS(40)         TYPE C,
       CHECK_AMOUNT(40)   TYPE C,
       END OF EXTRACTREC.

DATA: EXT TYPE EXTRACTREC OCCURS 100  WITH  HEADER LINE.


DATA: v_RWBTR1(20) TYPE C,
           v_count1(20) TYPE C.

DATA  IT_PAYR LIKE PAYR OCCURS 100 WITH HEADER LINE.

DATA: wk_dow       TYPE C,
          wk_days      TYPE i.

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 = '6'.
*    OR wk_dow = '7' .
      r_weekend = 'IEQ'.
      r_weekend-low = p_dates-low.
      APPEND r_weekend.
*      WRITE:/ p_dates-low.

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.

CLEAR:  v_RWBTR1,
              v_count1.

SELECT * FROM PAYR  WHERE  ZALDT in R_DATE1.
      MOVE-CORRESPONDING PAYR TO IT_PAYR.
      APPEND IT_PAYR.
      clear it_payr.

 ENDSELECT.

SORT IT_PAYR BY ZALDT.

LOOP AT IT_PAYR where zaldt in r_date1.

v_RWBTR1 = v_RWBTR1 + it_payr-RWBTR.
v_count1 = v_count1 + 1.

ENDLOOP.
   CLEAR EXT.
   EXT-WEEKEND =   P_DATES-LOW.
   EXT-CHECKS  = V_COUNT1.
   EXT-CHECK_AMOUNT = V_RWBTR1.

   APPEND EXT.

WRITE:/ EXT-WEEKEND, EXT-CHECKS, EXT-CHECK_AMOUNT.

    ENDIF.
    p_dates-low = p_dates-low + 1.
  ENDWHILE.

I tried using loop at ext

AT END OF WEEKEND+4(2)

sum

write:/ ext-checks.

endloop.

But it is not working.

PLease help me in getting the totals for change of month from this code.

Thanks & Regards,

Dan