Make your own free website on Tripod.com
 

SAP ABAP Programming, Functional and Basis Components Books


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.

Back to Previous

Return to SAP Hints and Tips on Configuration and ABAP/4 Programming