OY05 - Maintain the SAP Factory Calendar

SAP Factory Calendar allows companies to key in their own factory work days.  Individual SAP application such as MRP will take into consideration these individual factory customizing.

For alternate Saturday, you set Saturday as a normal working day and key in all the off-days in the Special rules button.

In your abap program, you can calculate whether a particular day is a non-working day, with reference to the Factory Calendar.

ABAP Program to check for holidays using the factory calendar
* include zday .
* substitute tdate = 'yyyymmdd'.
* tholiday_found   = 'X'   -> Holiday
TABLES THOCS.
DATA: BEGIN OF INT_THOCS OCCURS 100,
      THOCS LIKE THOCS.
DATA: END OF INT_THOCS.

DATA: TDAY(1),
      TDATE LIKE SY-DATUM,
      THOLIDAY_ATTRIBUTES,
      THOLIDAY_FOUND(1).

FORM HOLIDAY.
CALL FUNCTION 'HOLIDAY_CHECK_AND_GET_INFO'
     EXPORTING
          DATE                         = TDATE
          HOLIDAY_CALENDAR_ID          = 'XX'
*         WITH_HOLIDAY_ATTRIBUTES      = ' '
     IMPORTING
          HOLIDAY_FOUND                = THOLIDAY_FOUND
     TABLES
          HOLIDAY_ATTRIBUTES           = INT_THOCS
     EXCEPTIONS
          CALENDAR_BUFFER_NOT_LOADABLE = 1
          DATE_AFTER_RANGE             = 2
          DATE_BEFORE_RANGE            = 3
          DATE_INVALID                 = 4
          HOLIDAY_CALENDAR_ID_MISSING  = 5
          HOLIDAY_CALENDAR_NOT_FOUND   = 6
          OTHERS                       = 7.

CALL FUNCTION 'DATE_COMPUTE_DAY'
     EXPORTING
          DATE    = TDATE
     IMPORTING
          DAY     = TDAY
     EXCEPTIONS
          OTHERS  = 1.
* For checking.
*if tholiday_found = 'X'.
*   write: /1 'Holiday ', tdate.
*else.
*   write: /1 'Not Holiday ', tdate.
*endif.
*
*case sy-subrc.
*   when 0.       write: /1 tdate, tday.
*   when others.  write: /1 'Unknown day ', tdate.
*endcase.
ENDFORM.

More Function Module
Functions / SAP Script / ALV

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.