Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Knowing the days of the month of the specific year...

Former Member
0 Kudos

Hi Guys,

I am doing a report which would output a number of days of the month in the specific year. The days will be below the specific month in rows...

Example: There are 31 days for the month of october... 28 days for february for year 2007... 29 days of february for year 2008...

May I know how am I going to achieve this?

All your help will be greatly appreciated.

Thanks!

Mark

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI MARK.

<b>Use the FM: NUMBER_OF_DAYS_PER_MONTH_GET</b>

pass month number and year.. and u will get days.

data: days LIKE T009B-BUTAG.

CALL FUNCTION <b>'NUMBER_OF_DAYS_PER_MONTH_GET'</b>

EXPORTING

par_month = sy-datum+4(2)

par_year = sy-datum+0(4)

IMPORTING

PAR_DAYS = days

.

write days.

6 REPLIES 6

Former Member
0 Kudos

Hi..

Use this FM

NUMBER_OF_DAYS_PER_MONTH_GET

Regards

Bala.

Former Member
0 Kudos

refer this site.

Former Member
0 Kudos

Hi,

Try this.

HR_E_GET_SI_DAYS_TO_WORK - this function module excludes the saturdays and sundays.

or

Try using the FM , CATSXT_GET_HOLIDAYS for finding out no of days defined as holidays in the SAP HR Module.It will give you entries as dates which falls on Holidys in an internal table. Take a count of the internal table.

Can use FM HR_SGPBS_YRS_MTHS_DAYS for finding out no of days between a date range.

Subtract the days between ranges and the no of holidays between them.

REPORT zforum_days .

DATA: wa_days TYPE i.

PARAMETERS: wa_frdat TYPE sy-datum DEFAULT '20051216',

wa_todat TYPE sy-datum DEFAULT '20051221'.

PERFORM get_days USING wa_frdat wa_todat CHANGING wa_days.

WRITE: 'No. of days: ', wa_days.

&----


*& Form GET_DAYS

&----


  • text

----


  • -->P_WA_FRDAT text

  • -->P_WA_TODAT text

  • <--P_WA_DAYS text

----


FORM get_days USING p_wa_frdat

p_wa_todat

CHANGING p_wa_days.

DATA : tot_days TYPE i,

tot_holi TYPE i.

DATA : holi_table TYPE catsxt_iscal_day_itab.

DATA: lin TYPE i,

ini TYPE i,

knd TYPE c.

CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'

EXPORTING

beg_da = p_wa_frdat

end_da = p_wa_todat

IMPORTING

  • NO_DAY =

  • NO_MONTH =

  • NO_YEAR =

no_cal_day = tot_days

EXCEPTIONS

dateint_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'CATSXT_GET_HOLIDAYS'

EXPORTING

im_personnel_number = '00000024'

im_begin_date = p_wa_frdat

im_end_date = p_wa_todat

im_get_weekend_days = 'X'

IMPORTING

ex_holidays = holi_table.

DESCRIBE TABLE holi_table LINES lin OCCURS ini KIND knd.

p_wa_days = tot_days - lin.

ENDFORM. " GET_DAYS

or try this.

data : num type i.

parameters : frdate type sy-datum default '20051216'.

parameters : todate type sy-datum default '20051221'.

DATA : d TYPE sy-datum.

d = fromdate - 1.

DO.

d = d + 1.

IF d > todate.

EXIT.

endif.

CALL FUNCTION 'DATE_CHECK_WORKINGDAY'

EXPORTING

date = d

factory_calendar_id = '01'

message_type = 'I'

EXCEPTIONS

date_after_range = 1

date_before_range = 2

date_invalid = 3

date_no_workingday = 4

factory_calendar_not_found = 5

message_type_invalid = 6

OTHERS = 7.

IF sy-subrc = 0.

numofdays = numofdays + 1.

write 😕 d.

ENDIF.

ENDDO.

the above code will give u the NUMBER OF DAYS,AS WELL AS ALL THE DATES,excluding the weekends.

Reward if Useful.

Regards,

Chitra

former_member386202
Active Contributor
0 Kudos

Hi,

Check table TFACS

Regards,

Prashant

Former Member
0 Kudos

Hi Mark,

try this code...


DATA : mm LIKE t009b-bumon,
yy LIKE t009b-bdatj,
days LIKE t009b-butag.

PARAMETERS : mmyy LIKE isellist-month DEFAULT '200802'.
mm = mmyy+4(2).
yy = mmyy+0(2).


CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'
  EXPORTING
    par_month = mm
    par_year  = yy
  IMPORTING
    par_days  = days.
WRITE 😕 days.

Former Member
0 Kudos

HI MARK.

<b>Use the FM: NUMBER_OF_DAYS_PER_MONTH_GET</b>

pass month number and year.. and u will get days.

data: days LIKE T009B-BUTAG.

CALL FUNCTION <b>'NUMBER_OF_DAYS_PER_MONTH_GET'</b>

EXPORTING

par_month = sy-datum+4(2)

par_year = sy-datum+0(4)

IMPORTING

PAR_DAYS = days

.

write days.