Skip to Content
0
Former Member
Feb 24, 2009 at 12:02 PM

how can i find the maximum check's in a month

60 Views

Dear Freinds

i have requirement where i have to check on week end (sunday) holiday , if the employee works i have to check how many hours he has worked. So i wanted to get from previous day what is the daily wages paid per hourly snce saturday is working day. This iam able to achive to get ther previous for today(sunday) as saturday by using the function module

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = fp_v_date

days = fp_v_days "1

months = 0

signum = '-'

years = 0

IMPORTING

calc_date = fp_prev_date.

so the fp_prev_date iam checking for this date is a holiday ?

by reading from the table THOL. If the feild klass eq 1 in the tableThol then it is assume as holiday else is working day. Till here it is working perfectly

Now, i have is if iam checking for one day this logic holds good .But however if i wanted to check if the fp_prev_date is holiday then my requirement is i have to go further ( i.e friday) by one day and check the return day , if that is also holiday then i have to go still further ......so i wanted to check all the 31 or 30 or 28 days in that month till i found regular day ( i.e THOL-KLASS NE 1) So i wanted to put this logic in a common code and check every day . Can any body give me good logic.

As of now i have written as below.

IF fp_v_day IS NOT INITIAL. ( note : fp_v_day is the day iam gettin based on selection screen date)

PERFORM get_prev_day USING fp_v_day

'01'

CHANGING prev_date

v_holid.

IF v_holid IS NOT INITIAL.

fp_v_day = fp_v_day + 1. " friday

clear v_holid.

PERFORM get_prev_day USING fp_v_day

'01'

CHANGING prev_date

v_holid.

IF v_holid IS NOT INITIAL.

fp_v_day = fp_v_day + 1. "thursday

clear v_holid.

PERFORM get_prev_day USING fp_v_day

'01'

CHANGING prev_date

v_holid.

IF v_holid IS NOT INITIAL.

fp_v_day = fp_v_day + 1. "wednesday

clear v_holid.

PERFORM get_prev_day USING fp_v_day

'01'

CHANGING prev_date

v_holid.

endif.

endif.

endif.

endif.

-


PERFORM get_prev_day USING fp_v_day

'01'

CHANGING prev_date

v_holid.

this subroutine have the below code.

FORM get_prev_day USING fp_v_date

fp_v_days type DLYDY

CHANGING fp_prev_date

fp_v_holid.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = fp_v_date

days = fp_v_days "2

months = 0

signum = '-'

years = 0

IMPORTING

calc_date = fp_prev_date.

IF fp_prev_date IS NOT INITIAL.

SELECT * FROM thoc WHERE ident = 'ET'

AND datum = fp_prev_date.

SELECT SINGLE * FROM thol WHERE ftgid = thoc-ftgid.

  • AND klass = '1'.

IF sy-subrc EQ 0.

IF thol-klass EQ '1'. " Public Holiday.

MOVE 'X' TO fv_holid.

ENDIF.

ENDIF.

ENDIF.

ENDFORM.

in the above logic i have iwriten

IF v_holid IS NOT INITIAL.

fp_v_day = fp_v_day + 1. " saturday

clear v_holid.

PERFORM get_prev_day USING fp_v_day

'01'

CHANGING prev_date

v_holid.

etc i have to write 31 times and check in that month it fits or not .......if any body could please give me a better way of writting only one time subrotine( i.e calling this subrutine for all the days in the month) and checking instead me writing 31 or 30 times in that month.

regards

divya.