Monday, June 15, 2015

Function to return next business day

Function to return next business day

A function that will return next business day, based on the country.
This function will allow users to specify e.g. 10 business days from now.

Here is the code.

Code:
REPORT  ZRM_TEST                      .

PARAMETERS: DATE_1 LIKE SY-DATUM DEFAULT SY-DATUM,
BIZ_DAYS TYPE I DEFAULT 2,
FACCALID LIKE SCAL-FCALID DEFAULT 'US'.

DATA:       FAC_DATE_1 LIKE SCAL-FACDATE,
DATE_2 LIKE SY-DATUM,
FAC_DATE_2 LIKE SCAL-FACDATE.

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
DATE                         = DATE_1
FACTORY_CALENDAR_ID          = FACCALID
IMPORTING
FACTORYDATE                  = FAC_DATE_1 .
FAC_DATE_2 = ABS( FAC_DATE_1 + BIZ_DAYS ).

CALL FUNCTION 'FACTORYDATE_CONVERT_TO_DATE'
EXPORTING
factorydate                        = FAC_DATE_2
factory_calendar_id                = FACCALID
IMPORTING
DATE                               = DATE_2
.
WRITE: / DATE_2.

You can also try the function module DAY_ATTRIBUTES_GET.
You need to provide the calendar and a time interval, and the fm returns an internal table showing days with flags holiday / working day.

No comments:

Post a Comment